How To Reset After Merging A Git PR By Mistake
By mistake I merged a git pull request (someone else has to merge it, not me...) how can I roll back and create the pull request again
this is what I did:
1) created a pull request to merge branchA into branchB (PR #44)
2) (by mistake) merged the pull request #100 (on GitHub site)
3) Clicked the Revert button to "create a new pull request to revert these changes" (PR #45)
4) Merged pull request #45
Now I am trying to again create a pull request to merge branchA into branchB but it does not let me because "There aren't any commits to merge" (I am using git desktop gui on Mac)
Should I reset branchB to the last commit before action (1) ?
And then create a pull request to merge branchA into branchB ?
If yes, how? Would this be correct?
When on branchB:
git reset --hard 4f5oo77
git commit -am "reset to the last commit before merging PR 44"
git push origin
EDIT: this is the log history on branchB
I wan to go back to commit "4f5oo77 2015-12-01 | Merge pull request #36 from my-repo/branchA"
* 87a8888 2015-12-16 | Merge pull request #45 from my-repo/revert-44-branchA (HEAD, origin/branchB, branchB)
|\
| * 55bd11c 2015-12-16 | Revert "merge branchA" (origin/revert-44-branchA)
|/
* y77447a 2015-12-16 | Merge pull request #44 from my-repo/branchA
|\
....
| |/
* | 4f5oo77 2015-12-01 | Merge pull request #36 from my-repo/branchA
...
EDIT-2 This is what ended up doing:
git checkout branchB
git reset --hard 4f5oo77
git push --force-with-lease
At this point branchB was back to its "state" before the unwanted merges and I was able to create a pull request for merging branchA into branchB
Answer
Except if you REALLY can't modify an history that you already shared (pushed), I think that it's much better to use 'git reset' and 'git push --force-with-lease' instead of ditching your history by stacking revert commits!
Related Questions
- → Authenticate with a cookie using laravel 5.1 and jwt
- → Finding a specific GitLab tag from PHP
- → React: How to publish page on server using React-starter-kit
- → babel-loader, webpack, ES2015 modules: "Element type is invalid"
- → Create a function-attribute of a function, which is, in its turn, a method of an object literal
- → Model Validation in laravel 5.1 not working
- → GIT fatal: loose object
- → Laravel validation required rule not working
- → Axios array map callback
- → Where does this `webpack://` come from for `webpack-dev-middleware`?
- → error when trying to modify project in laravel forge
- → GitHub Pages and Jekyll content duplication and SEO issues
- → Use Laravel repositories with Datatables