首先我知道这个问题How do I tell git to always select my local version for conflicted merges on a specific file?但这篇文章对我没有帮助,而且由于我的声誉,我无法添加任何评论。
http://git-scm.com/book/en/Customizing-Git-Git-Attributes建议将路径的 merge 策略设置为我们的,而不是设置自定义 merge 驱动程序。
添加自定义 merge 驱动程序返回退出代码 0 的好处和区别是什么?
我的存储库顶层有一个 .gitattributes 文件:
pom.xml merge=ours
但是当我将两个分支与更改的 pom.xml 文件 merge 时, merge 无法解决:
$ git merge origin/master
Auto-merging pom.xml
CONFLICT (content): Merge conflict in pom.xml
Automatic merge failed; fix conflicts and then commit the result.
我得到了一个标准的 merge 冲突结果:
<pom>
<<<<<<< HEAD
<version>0.88-SNAPSHOT</version>
=======
<version>0.87.0</version>
>>>>>>> origin/master
</pom>
我做错了什么?
最佳答案
您可以声明 merge 驱动程序,但这意味着您必须在 git 配置上定义它,如“.gitattributes
& individual merge strategy for a file ”:
[merge "ours"]
name = "Keep ours merge"
driver = true
这允许对一个文件或一组文件进行 merge 策略,而不是 git merge
的 -s
选项。 <强> strategies ,它不需要您定义驱动程序,但可以解决所有文件(不仅仅是pom.xml
)的冲突
git merge -s ours
关于git - .gitattributes merge 驱动程序未使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22577405/