在git中解决'both added'合并冲突? [英] Resolving a 'both added' merge conflict in git?

查看:6100
本文介绍了在git中解决'both added'合并冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git中重新绑定,并且我得到的一个冲突是两个都添加了 - 也就是说,我的分支中独立添加了完全相同的文件名,并且我正在重新设置分支。 git status 告诉我:

 #未合并路径:
#(使用git reset HEAD< file> ...来取消)
#(使用git add / rm< file> ...来标记分辨率)

#同时添加:src / MyFile.cs

我的问题是,如何解决此问题?我必须使用合并工具,还是有办法从命令行执行?如果我 git rm src / MyFile.cs ,git如何知道我想删除哪个文件版本以及我想保留哪个版本?


<如果你使用 git rm git会从索引中删除该路径的所有版本,所以你的解决方案将会您可以使用 git checkout --ours src / MyFile.cs 来选择版本来自您正在重新绑定的分支或 git checkout - 他们的src / MyFile.cs 从分支中选择版本。



如果您想要混合,您需要使用合并工具或手动编辑它。


I'm rebasing in git, and one conflict I get is 'both added' - that is, exactly the same filename has been added independently in my branch, and in the branch I'm rebasing on. git status tells me:

# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#       both added:         src/MyFile.cs

My question is, how do I resolve this? Must I use a merge tool or is there a way I can do it just from the commandline? If I git rm src/MyFile.cs, how does git know which file version I want to remove and which I want to keep?

解决方案

If you use git rm git will remove all versions of that path from the index so your resolve action will leave you without either version.

You can use git checkout --ours src/MyFile.cs to choose the version from the branch onto which you are rebasing or git checkout --theirs src/MyFile.cs to choose the version from the branch which you are rebasing.

If you want a blend you need to use a merge tool or edit it manually.

这篇关于在git中解决'both added'合并冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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