Git冲突"都被删除"

use*_*592 13 git merge conflict delete-file

我不明白为什么"两个删除"都是未合并路径的状态.

如果:

  • OldStandard是基地
  • NewStandard是主干上的最后一次提交
  • OldCustom是我们尝试在master中合并的分支(来自OldStandard的分支)

为什么与标记为"已删除"的某些文件存在冲突?

在NewStandard中添加一个文件时,我理解"两者都添加"的冲突,并且在OldCustom中添加了另一个版本的文件.

但是,对于删除,如果文件已在NewStandard中删除,并且在OldCustom中也被删除了,会出现什么问题?那是一个等同的国家,不是吗?

LeG*_*GEC 6

该答案所述(建议重复):

你可以看到一个“既删除”时,branchA有一个git mv oldfile newstandard承诺,和branchB有一个git mv oldfile newcustom承诺。

在这种情况下,尝试合并customBranch到时standardBranchgit将报告三个文件的冲突:

both deleted:  oldfile
added by them: newcustom
added by us:   newstandard
Run Code Online (Sandbox Code Playgroud)

像任何冲突一样,最终的选择权掌握在您的手中:

git只是强调这样一个事实,也许有可能是在事实问题newcustomnewstandard您的最终代码版本住在一起,也许这可能与这两个被作为副本创建的事实oldfile

您可以手动修复该问题:

  • 如果去除oldfile是预期的结果:git reset oldfile && git rm oldfile
  • 如果保管newstandard是预期的结果,删除其他:git reset newcustom && git rm newcustom
  • 如果一些地区newstandardnewcustom应合并:编辑他们的手,或用3路合并工具:meld newstandard newstandard newcustom
  • 等...