我正在尝试理解 git union merge 的一个令人费解的行为。要重现,请从具有以下内容的 hello.txt 开始:
1
2
3
在另一个提交中,添加一行,例如
1
2
new
3
在原始提交的不同 foo
分支中,删除中间行:
1
3
在这里我希望 merge 不包含删除的行,即使在使用联合 merge 时也是如此。但是我看到它包含(在主服务器上运行 git merge foo
之后。):
1
2
new
3
所以它忽略了我的行删除。我只是误解了 union merge 的工作原理吗?示例 repo :https://github.com/davidebbo/MergeTest
还有一点要注意:如果您没有删除第 2 行,而是删除第 1 行,那么 merge 会按预期发生,最后是:
2
new
3
所以奇怪的事情似乎只发生在标准(非联合) merge 下会导致冲突的场景中。
最佳答案
--union merge 正常工作。查看git-merge-file手册页:
Instead of leaving conflicts in the file, resolve conflicts favouring both side of the lines.
第二种情况根本算不上冲突。修改后的行不相邻(#1 和#3)。
关于git union merge 带回一些删除的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12947436/