Git 冲突 "both deleted"

Git conflict "both deleted"

我不明白为什么 "both deleted" 是未合并路径的状态。

如果:

为什么与一些标记为 "both deleted" 的文件有冲突?

我理解 "both added" 的冲突,当在 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 只是强调 可能 可能存在问题 newcustomnewstandard 住在你的房子里最终代码版本,并且 可能 这可能与两者都是通过 oldfile.

的副本创建的事实有关

您可以手动修复该问题:

  • 如果删除 oldfile 是预期的结果:git reset -- oldfile,
  • 如果保留 newstandard 是预期的结果,请删除另一个:git reset newcustom && git rm newcustom
  • 如果 newstandardnewcustom 的某些部分应该合并:手动编辑它们,或使用三向合并工具:meld newstandard newstandard newcustom
  • 等...