Git - revert to branches after failed merge?

18,225

It seems to me you simply want to abort the merge. The modern way to do this is:

git merge --abort

And the slightly older way:

git reset --merge

The old-school way would be (warning: will discard all your local changes):

git reset --hard

It's 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. This is why i find git reset --merge to be much more useful in everyday work.

In your case, any of the alternatives will work as you don't have a failed merge but just an ongoing merge you want to abort.

Share:
18,225

Related videos on Youtube

pastic
Author by

pastic

Updated on June 04, 2022

Comments

  • pastic
    pastic almost 2 years

    I have two branches, the head of each is at the respective last commit. If I merge the two, and there are conflicts I can't resolve (I am new to Git), can I simply checkout the last commits before the merge and have another go at it or attempt another strategy?