Reputation: 28556
I've done merge some-branch
into master
, but gets confilcts. How to undo this ?
git checkout master
git merge some-branch
...
CONFLICTS :(
Upvotes: 6
Views: 7189
Reputation: 18109
With modern git, you can, as suggested in previous answer:
git merge --abort
Older syntax:
git reset --merge
Old-school, also suggested in previous answer:
git reset --hard
But actually, it is worth noticing that git merge --abort
is only equivalent to git reset --merge
given that MERGE_HEAD
is present. This can be read in the git help for merge command.
git merge --abort is equivalent to git reset --merge when MERGE_HEAD is present.
After a failed merge, when there is no MERGE_HEAD
, the failed merge can be undone with git reset --merge
but not necessarily with git merge --abort
, so they are not only old and new syntax for the same thing.
Personally I find git reset --merge
more useful in everyday work so this is the method i use all the time.
Upvotes: 1
Reputation: 129566
git merge --abort
is a recently added option. It does what you expect.
Upvotes: 15
Reputation: 2583
If you have conflicts, your merge will not be committed yet so you can use git reset --hard HEAD
to remove the merge.
Upvotes: 3