2

起初,我知道这个问题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建议将合并策略设置为我们的路径,而不是设置自定义合并驱动程序。

添加自定义合并驱动程序返回退出代码 0 的好处和区别是什么?

我的仓库顶层有一个 .gitattributes 文件:

pom.xml merge=ours

但是,当我将两个分支与已更改的 pom.xml 文件合并时,无法解决合并问题:

$ 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.

我得到一个标准的合并冲突结果:

<pom>
<<<<<<< HEAD
    <version>0.88-SNAPSHOT</version>
=======
    <version>0.87.0</version>
>>>>>>> origin/master
</pom>

我究竟做错了什么?

4

1 回答 1

3

您可以声明一个合并驱动程序,但这意味着您必须在 git 配置中定义它,如“ .gitattributes& individual merge strategy for a file ”:

[merge "ours"]
    name = "Keep ours merge"
    driver = true

这允许一个文件或一组文件的合并策略,而不是 strategy选项-s,它不需要您定义驱动程序,但可以解决所有文件的冲突(不仅仅是 for )git merge pom.xml

git merge -s ours
于 2014-03-22T15:31:54.720 回答