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…
- GitHub: How to send one pull request per separate commit?
- How do I get commits from a merged and reverted PR into a new one?
- How to Clone a private repository of github organization in a Jenkins Job
- Working with abandoned pull requests on Github (keeping history)
- Apply Bitbucket pull request as a patch
- Bitbucket CRLF issue?
- To make things transparent I created a pull request.
- My collaborator (complete git/github newbie) clicked to merge the pull request (probably just exploring the interface).
- 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
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
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
master while the actual difference is different). What is the easiest way to do so?
3 Solutions collect form web for “Pull request merged, closed, then reverted – now can't pull the branch again”
Instead of trying to fiddle with
B, you could simply:
- create a new branch
- starting with a previous commit from
B(where the merge was easy)
- cherry-pick any commit from
Byou need back in
You can then make a PR from
C if you want.
I know this is an old question, but I just had the same problem and found an easy get-around:
I just created a new branch from master and replaced the contents of the project folder with the ones I had in the branch I was working on before. (Literally copied and pasted the folder contents). After this, when I ran
git status, it showed the correct modifications.
It’s a more primitive solution but it works, and after that I was able to create the PR which showed the correct changes from master and the branch I was working on.
I think the cleanest solution is to create a new branch off master and then revert the commit that reverted your PR. Something like:
git checkout master git checkout -b retry_B # create new branch git log # find commit hash for the revert git revert <hash_from_revert>