Git合并策略'他们'并不能解决修改/删除冲突 [英] Git merge strategy 'theirs' is not resolving modify/delete conflict

查看:1386
本文介绍了Git合并策略'他们'并不能解决修改/删除冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下选项执行 git merge 时:

git merge - X他们的主人



偶尔有冲突的文件会如此:


CONFLICT(修改/删除):在master中删除File_A.java,在HEAD中修改


然而,我希望 -X他们的选项在这些情况下被识别,并使用 删除版本的版本 strong>



是否有这种冲突不会自动解决的原因,尤其是 ,因为我提供了一个特定的合并策略,应该如何删除文件?



另外,如何更新我的 merge 命令以使用他们的这种类型的冲突版本?

解决方案

(这是你实际使用的,参见[1])不影响树合并,它是$ c>仅在两个文件仅被修改时才用于文件内容合并。我不知道是否有任何合并命令选项可以做你想做的事。你可以尝试制作一个脚本来扫描冲突的文件(使用 git status --polcelain ),然后删除文件( git rm --force ( git checkout - 他们的< file> )或者获得它的远程版本

[1] https://www.kernel.org/pub/software/scm/git/docs/git-merge.html#_merge_strategies


When performing a git merge with the following options:

git merge -X theirs master

There are occasionally conflicted files like so:

CONFLICT (modify/delete): File_A.java deleted in master and modified in HEAD. Version HEAD of File_A.java left in tree.

However, I would like for the -X theirs option to be recognized in these cases, and use the theirs version of the change, which is for the file to be deleted.

Is there a reason this type of conflict is not automatically resolved, especially since I'm providing a specific merge strategy that suggests it should remove the file?

Further, how (if possible) can I update my merge command to use the theirs version of this type of conflict?

解决方案

Looks like theirs option of recursive strategy (this is what you actually use, see the [1]) does not affect tree merging, it is used only for file content merging when both files modified only. I don't really know if there is any merge command option which can do what you want. You could try to make a script which scans conflicted files (with git status --porcelain) and then either removes the file (git rm --force <file>) or get the remote version of it (git checkout --theirs <file>)

[1] https://www.kernel.org/pub/software/scm/git/docs/git-merge.html#_merge_strategies

这篇关于Git合并策略'他们'并不能解决修改/删除冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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