我遇到了合并冲突。我如何中止合并? [英] I ran into a merge conflict. How can I abort the merge?
问题描述
我使用了 git pull
并发生了合并冲突。我知道该文件的其他版本很好,而且我的文件很糟糕,所以我的所有更改都应该放弃。
I used git pull
and had a merge conflict. I know that the other version of the file is good and that mine is bad so all my changes should be abandoned. How do I do this?
unmerged: _widget.html.erb
You are in the middle of a conflicted merge.
推荐答案
code>不成功,然后 HEAD
(不是 HEAD ^
)是分支上的最后一个有效提交:
Since your pull
was unsuccessful then HEAD
(not HEAD^
) is the last "valid" commit on your branch:
git reset --hard HEAD
您想要的另一件事是让他们的更改胜过您的更改。
The other piece you want is to let their changes over-ride your changes.
旧版本的git允许您使用他们的合并策略:
Older versions of git allowed you to use the "theirs" merge strategy:
git pull --strategy=theirs remote_branch
但是,在 Junio Hamano发布的此消息(Git维护者)。正如链接中所述,您应该这样做:
But this has since been removed, as explained in this message by Junio Hamano (the Git maintainer). As noted in the link, instead you would do this:
git fetch origin
git reset --hard origin
这篇关于我遇到了合并冲突。我如何中止合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!