我遇到了合并冲突.如何中止合并? [英] I ran into a merge conflict. How can I abort the merge?

查看:20
本文介绍了我遇到了合并冲突.如何中止合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 git pull 并且发生了合并冲突:

I used git pull and had a merge conflict:

unmerged:   _widget.html.erb

You are in the middle of a conflicted merge.

我知道该文件的另一个版本是好的,而我的则是坏的,因此应该放弃我的所有更改.我该怎么做?

I know that the other version of the file is good and that mine is bad so all my changes should be abandoned. How can I do this?

推荐答案

既然你的 pull 不成功那么 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆