Reputation: 575
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?
Upvotes: 2
Views: 18510
Reputation: 18129
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.
Upvotes: 1