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?
Asked
Active
Viewed 1.8k times
2
-
Check those two posts http://stackoverflow.com/questions/2389361/undo-a-git-merge-that-hasnt-been-pushed-yet and http://stackoverflow.com/questions/7099833/how-to-revert-a-merge-commit-thats-already-pushed-to-remote-branch. You should be able to find an answer. – Kamil Apr 05 '16 at 19:17
1 Answers
1
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.

Martin G
- 17,357
- 9
- 82
- 98