revert to branches after failed merge?
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?
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.
链接地址: http://www.djcxy.com/p/49838.html上一篇: Git恢复特定的合并提交
下一篇: 合并失败后恢复为分支?