Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pull request merged, closed, then reverted - now can't pull the branch again

GitHub seems to be a bit lost after a couple of operations - and I certainly am...

So, here is the story:
I am new to git, and new to github. In my repository I had a branch (let's call it B) where I was working on a feature.

  1. To make things transparent I created a pull request.
  2. My collaborator (complete git/github newbie) clicked to merge the pull request (probably just exploring the interface).
  3. The feature was not ready so I reverted the merge.

Now I would like to continue my work on the branch B and later merge it, but although the branch is is different by more than 800 lines GitHub shows that there is only one line of difference (one commit).

This may be because I was trying to reopen the old pull request after reverting the changes. I did reopen the pull request but the option to merge was no longer available. I tried closing or opening the old pull request and creating a new pull request (pulling branch B to master) but this shows only one commit as if all the rest was eaten up by the original pull request (although reverted). But if I try to pull master to B - it shows all the differences (about +800/-300 difference).

I would like to be back to work peacefully on branch B - I would like to be back to the moment when B could be automatically merged (now it is not possible becasue new pull requests show only one minor difference between B and master while the actual difference is different). What is the easiest way to do so?

like image 848
mmagnuski Avatar asked Aug 25 '14 11:08

mmagnuski


People also ask

What happens when you revert a merge request?

When you revert a merge commit, the branch you merged to (usually main ) is always the first parent. To revert a merge commit to a different parent, you must revert the commit from the command line: Identify the SHA of the parent commit you want to revert to.

How do I reopen a reverted pull request on GitHub?

You need the rights to reopen pull requests on the repository. The pull request hasn't been merged, just closed. Go to Pull requests add filter `is:closed` choose PR you want to reopen.

Can you revert a merged pull request?

You can revert a pull request after it's been merged to the upstream branch.


1 Answers

Instead of trying to fiddle with B, you could simply:

  • create a new branch C,
  • starting with a previous commit from B (where the merge was easy)
  • cherry-pick any commit from B you need back in C

You can then make a PR from C if you want.

like image 121
VonC Avatar answered Oct 04 '22 13:10

VonC