4

Say you are in a branch topic, you have been working for a while and want to merge in some commits from master.

You run git merge and there are a few conflicts. But you don't have time to resolve the merge conflicts now, and you want to return to the state that you were in before running git merge.

There are three ways of which I know to do this:

  • git merge --abort
  • git reset --merge
  • git reset --hard HEAD ?

Is any one of the three acceptable? What is the difference between them in this case?

Marco Prins
  • 7,189
  • 11
  • 41
  • 76

1 Answers1

3

git merge --abort is preferable to git reset --hard HEAD, because (from git merge man page) it will remove .git/MERGE* files (like MERGE_HEAD).
git reset --hard will not, which means git will believe a merge is still in progress.

And git reset --merge is simply what was used before git merge --abort was introduced (in git 1.7.4, as I mentioned here).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @Vonc +1 You never cease to amaze me with your high quality version control answers since I started noticing your name when I was answering clearcase questions. Your high reputation is clearly well earned. – hlovdal May 21 '14 at 16:38
  • @hlovdal Thank you :) As you can see by the graph with my name on it, I have been working hard for that reputation: http://meta.stackoverflow.com/a/252757/6309 – VonC May 21 '14 at 20:06