0

I have two branches, bb and master. I worked on bb, made some changes, pushed them to Github, and made a pull request that I merged into master. I then saw a problem with a production app and thought there was a problem with the changes in bb, so I clicked the revert button on Github.

It turned out that the problem was not with the code but with a data file that was needed by the changes in bb that I hadn't uploaded to the server, so I wanted the changes from bb merged into master after all ... so, I made a meaningless change in bb (added some whitespace) to get a new PR. But the PR was just for the whitespace, not for all the other changes in bb relative to master. I merged the PR, but sure enough only the whitespace change was applied.

So now Github has two versions of a file foo.py, one in bb and one in master, and when I try to make a pull request, it tells me that "There isn’t anything to compare. master is up to date with all commits from bb". Huh?

How can I get Github to actually merge the changes from foo.py in bb into master? (I think it's thrown off because it has previously merged exactly these changes ... but the current state of foo.py in master is different from in bb.)

1 Answer 1

3

Your easiest fix is to head to the terminal. Checkout the project if you haven't already.

git clone <url> my_project
cd my_project
git log (Find the id of the revert-- which is just a commit)
git revert (commit_id)

Then push your changes to bb and create a pull request for master

4
  • I can't revert the revert at this point because other people working on other branches have pushed changes to master that I would clobber. Crap, I think I just realized the problem. The problem is that the changes in bb are older than the changes in master. The only thing I can think of now is to do something really hacky like change foo.py to an empty file and commit and push, and then put the changes back in foo.py and I'll get the PR I want. Is there a better way?
    – dslack
    Commented Mar 23, 2016 at 16:45
  • Technically the commit is already in master. You could merge master into your branch and then make the changes. But I think you might be better off to create a new branch and then make the changes again. You could cherrypick the commit, but then you would end up back in the same spot. Because the commit is in master. So either merge master in and make the change or create a new branch off of master and make the changes. Commented Mar 23, 2016 at 17:11
  • Your changes will be in the history of the file. So I would just create a new branch do a compare with my old commit and grab the changes. Then commit and push. Create pull request and you are done. Commented Mar 23, 2016 at 17:28
  • 2
    The correct answer really is to revert the revert. It's important to realize that git revert <ID> does not mean "go back to the state as of <ID>". Revert turns a given commit ID into a patch and then "reverse-applies" the patch. Thus, if the change in <ID> was "remove line 17 of file X, change line 5 of file Y, and add new line 9 to file Z", reverting it means "put back line 17 in X, un-change 5 in Y, remove 9 in Z" (except that it is all done with context diffs and patching, which will require your help to merge if something else changed in or next to those lines).
    – torek
    Commented Mar 23, 2016 at 17:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.