[英]GIT: How to undo merge?
I've done merge some-branch
into master
, but gets confilcts. 我已经完成了将
some-branch
合并到master
,但是发生冲突。 How to undo this ? 如何撤消呢?
git checkout master
git merge some-branch
...
CONFLICTS :(
git merge --abort
is a recently added option. 是最近添加的选项。 It does what you expect.
它可以满足您的期望。
如果有冲突,您的合并将不会被提交,因此您可以使用git reset --hard HEAD
删除合并。
With modern git, you can, as suggested in previous answer: 使用现代git,您可以按照先前答案的建议进行操作:
git merge --abort
Older syntax: 较旧的语法:
git reset --merge
Old-school, also suggested in previous answer: 老式的,在以前的答案中也建议:
git reset --hard
But actually, it is worth noticing that git merge --abort
is only equivalent to git reset --merge
given that MERGE_HEAD
is present. 但实际上,值得注意的是,
MERGE_HEAD
存在git reset --merge
, git merge --abort
仅等效于git reset --merge
。 This can be read in the git help for merge command. 可以在git help for merge命令中阅读。
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
, so they are not only old and new syntax for the same thing . 合并失败后,如果没有
MERGE_HEAD
,则可以使用git reset --merge
撤消失败的合并,但不一定要使用git merge --abort
, 因此它们不仅是同一事物的新旧语法 。
Personally I find git reset --merge
more useful in everyday work so this is the method i use all the time. 我个人觉得
git reset --merge
在日常工作中更有用,所以这是我一直使用的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.