我不明白为什么“两者都已删除”是未合并路径的状态。
如果:
老标准是基础
NewStandard是主干上的最后一个提交
oldcustom是我们试图在master中合并的分支(来自oldstandard的fork)
为什么与标记为“两者都已删除”的某些文件存在冲突?
当一个文件被添加到NewStandard中,而另一个版本的文件被添加到OldCustom中时,我理解“两者都添加”的冲突。
但是,对于删除来说,如果文件在NewStandard中被删除,并且在OldCustom中也被删除,那么有什么问题呢?这是一个等价的状态,不是吗?
最佳答案
如this answer中所述(建议为副本):
当branchA
有一个git mv oldfile newstandard
提交,而branchB
有一个git mv oldfile newcustom
提交时,您可以看到“两者都已删除”。
在这种情况下,当尝试将customBranch
合并到standardBranch
时,git
将报告三个文件上的冲突:
both deleted: oldfile
added by them: newcustom
added by us: newstandard
就像任何冲突一样,最终的选择就掌握在你的手中:
git
只是强调了这样一个事实,即在最终的代码版本中,newcustom
和newstandard
可能存在问题,并且这可能与这两个版本都是通过复制oldfile
创建的事实相关联。您可以手动修复:
如果移除
oldfile
是预期结果:git reset oldfile && git rm oldfile
,如果保持
newstandard
是预期结果,则删除另一个:git reset newcustom && git rm newcustom
,如果应合并
newstandard
和newcustom
的某些部分:手动编辑它们,或使用三向合并工具:meld newstandard newstandard newcustom
等。。。