Basically I used Github revert button to revert a previous PR for a feature branch into master
, then I decided to merge the same feature br
I know this is old, but if someone need a good answer is here:
After you merge a PR and delete the brach and later revert this merge, you can create a new branch and then revert the revert. Push this to remote repo and create a new PR.
This will create a new PR with one commit named 'revert "revert #123 blabla"` with all your changes on diff.
https://www.tildedave.com/2012/11/24/reverting-a-github-pull-request.html
The reason you can't auto merge back in is because the base of the branch is out of sync with the HEAD of the master branch.
Reverting the Revert can get messy and sometimes lacks transparency.
Furthermore, reverting a revert will prevent other branches with this code from merging correctly.
Lets say you have feature x on master and merged into branch y. then you decide master shouldn't have had feature x merged in yet as it depends on branch y. So, you revert on master. When you try to merge branch x, git-merge command sees the original merge, and happily announces that all is well and branches have been already merged, omitting these commit for feature x, even though you wanted them merged with branch y.
You should pull the most recent master, rebase your branch on master and then you should be able to make another pull request.
Just revert the revert. So by clicking the revert button you will have created a new PR (your step 2). Once this is merged, you will have the option to revert this, which will create a new branch with all your changes back in. You can then pull this, make changes to it (if needed) and create a new PR. You will lose all the commit messages on Github, but all file changes will still be around. Good to refer to your original branch and reverts in the new PR.
Anything to avoid a complicated rebase or force pushing to master.
I am writing this answer since I faced this issue and I found the answers here more theoretical than practical. I surfed a little bit more and found the method to tackle this issue. You can find a more detailed answer in the article here.
To solve this problem you have to create a new branch tracking the master and revert the revert commit. Then checkout to feature branch and merge the new branch. Now you can resolve conflicts (if any), commit and create a new PR.
Here are the commands:
# do the needed changes in the feature branch
$ git commit -m "fixed issues in feature-branch'
# create new branch tracking master branch
$ git checkout -b revert-the-revert-branch -t master
# revert the reversion commit
# find it from your git log
# in linux try: 'git log | grep revert -A 5 -B 5'
$ git revert <revert-commit-hash>
# checkout the original feature branch
$ git checkout feature-branch
# merge the revert branch
$ git merge revert-the-revert-branch
# handle merge conflicts and commit and PR