没有使用.gitattributes合并驱动程序 [英] .gitattributes merge driver is not used
问题描述
http://git-scm.com/book/en/Customizing-Git-Git-Attributes 建议将合并策略设置为我们的路径,而不是设置自定义合并驱动程序。
添加自定义合并驱动程序的好处和不同之处返回退出代码0?
我有一个.gitattributes我的回购顶级文件:
pom.xml merge = our
pre>
但是,当我将两个分支合并到更改后的pom.xml文件时,无法解析合并:
$ git merge origin / master
自动合并pom.xml
CONFLICT(内容):在pom.xml中合并冲突
自动合并失败;修复冲突,然后提交结果。
我得到一个标准的合并冲突结果:
< POM>
<<<<<< HEAD
< version> 0.88-SNAPSHOT< / version>
=======
< version> 0.87.0< / version>
>>>>>>> origin / master
< / pom>
我做错了什么?
解决方案您可以声明合并驱动程序,但这意味着您必须在git配置中定义它,如
.gitattributes
&个别文件合并策略:
[合并我们的]
name =保留我们的合并
driver = true
这允许一个文件或一组文件的合并策略,相对于 -s 选项http://git-scm.com/docs/git-mergerel =nofollow noreferrer>
git merge
策略 ,它不需要您定义驱动程序,但可以解决所有文件的冲突(不仅限于pom.xml
)git merge -s our
At first, I know this question How do I tell git to always select my local version for conflicted merges on a specific file? but this post doesn't help me and I can't add any comments because of my reputation.
http://git-scm.com/book/en/Customizing-Git-Git-Attributes suggests to set the merge strategy to ours for the path instead of setting a custom merge driver.
What is the benefit and differene of adding a custom merge driver return an exit code 0?
I have a .gitattributes file on my repos top level:
pom.xml merge=ours
But when I merge two branches with changed pom.xml files the merge can't be resolved:
$ 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.
And I get a standard merge conflict result:
<pom> <<<<<<< HEAD <version>0.88-SNAPSHOT</version> ======= <version>0.87.0</version> >>>>>>> origin/master </pom>
What am I doing wrong?
解决方案You can declare a merge driver, but that means you have to define it on the git config, as in "
.gitattributes
& individual merge strategy for a file":[merge "ours"] name = "Keep ours merge" driver = true
That allows for a merge strategy for a file, or set of files, as opposed to the
-s
option forgit merge
strategies, which doesn't require you to define a driver, but which would resolve the conflict for all files (not just forpom.xml
)git merge -s ours
这篇关于没有使用.gitattributes合并驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!