I've done merge some-branch into master, but gets confilcts. How to undo this ?
git checkout master git merge some-branch ... CONFLICTS :( If you have conflicts, your merge will not be committed yet so you can use git reset --hard HEAD to remove the merge.
git reset --hardWith 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.
reset --hard.. you can cut yourself with that in other cases.