I merged my branch into master, and pushed, thinking all was well. Turns out the code has issues, and I would like a way to revert either the merge commit, or the entire branch, whichever is more appropriate, so that others can easily continue working as if my merge never happened.
Then I intend to fix my branch, and merge it in again. Reading man git-revert
suggests that I will be able to re-merge if I use -m to revert the entire branch.
Just reset HEAD to previous commit:
git reset --hard HEAD^
You don't state in your question if you pushed your faulty merge or not, so must push with --force if this is the case (since you have rewritten history on the master branch).
Note that rewriting history might cause problems for the other devs if they have based their work on top of the faulty commit. In this case you might want to consider:
git revert HEAD
However, this will create a new commit that does the opposite of the commit that HEAD points to right now and will taint the repository. Resetting is best in this sense since you get rid of two commits, one faulty and one to compensate for the faulty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With