git - .gitattributes merge 驱动程序未使用

标签 git merge git-merge gitattributes

首先我知道这个问题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/

相关文章:

Git - 从master更新当前分支而不提交当前分支更改

git - 为什么 git 显示两个明显相同的添加文件之间存在冲突?

git - 我可以删除除当前分支之外的所有本地分支吗?

file - 合并大文件的最佳方法是什么 (40gb+)

git - 在 git 中自动 merge 没有冲突(使用逐字比较而不是逐行)

json - Git 与 JSON 文件冲突

Mac 版 Git 安装程序 : Why is/usr/local/git/bin in my PATH?

git - 如何使 Gitlab runner 将代码 merge 到成功构建的分支中

mercurial: merge 期间如何 cherry-pick

git - 撤消 git merge 但添加 merge 后的提交