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
but now I'm getting this message with git status
:
# On branch master
# Your branch is ahead of 'origin/master' by 5 commits.
I don't want my branch to be ahead by any number of commits. How do I get back to that point?
The simplest of the simplest chance, much simpler than anything said here:
Remove your local branch (local, not remote) and pull it again. This way you'll undo the changes on your master branch and anyone will be affected by the change you don't want to push. Start it over.
Just for an extra option to look at, I've been mostly following the branching model described here: http://nvie.com/posts/a-successful-git-branching-model/ and as such have been merging with
--no-ff
(no fast forward) usually.I just read this page as I'd accidentally merged a testing branch instead of my release branch with master for deploying (website, master is what is live). The testing branch has two other branches merged to it and totals about six commits.
So to revert the whole commit I just needed one
git reset --hard HEAD^
and it reverted the whole merge. Since the merges weren't fast forwarded the merge was a block and one step back is "branch not merged".If you are in a middle of merging you can always abort it
git merge --abort