1 min read
Undo a pushed git merge
September 11, 2018
First of all the solution to the problem I am tackling should not exist in the first place. If you have to revert a merge on a git branch, think about alternatives. If not other option is left, I’ll show you how you can undo a merge with
First checkout your branch that has been targeted by the merge.
git checkout master
Have a look into the git log and look for the hash of the merge commit.
Now undo the merge using the revert command.
git revert -m 1 _COMMIT_HASH_
As mentioned undoing is a dangerous process. Depending on how far the merge commit is from the head of your branch you end up with a lot of conflicts.
Check the git repo for conflicts.
Once you have resolved the issues you can commit the revert commit.
Congrats! You did something were bad 😠
Categories: Software development