github undo merge - Undo a Git merge that hasn't been pushed yet

git undo merge attempt / git / undo / git-merge

Within my master branch, I did a git merge some-other-branch locally, but never pushed the changes to origin master. I didn't mean to merge, so I'd like to undo it. When doing a git status after my merge, I was getting this message:

# On branch master
# Your branch is ahead of 'origin/master' by 4 commits.

Based upon some instructions I found, I tried running

git revert HEAD -m 1
# On branch master
# Your branch is ahead of 'origin/master' by 5 commits.

emii



Answer #1

With newer Git versions, if you have not committed the merge yet and you have a merge conflict, you can simply do:

git merge --abort