有没有一种方法可以强制git merge始终使用外部合并工具? [英] Is there a way to force git merge to always use an external merge tool?

查看:246
本文介绍了有没有一种方法可以强制git merge始终使用外部合并工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过冲突合并始终通过外部合并工具来配置git merge?

Is there a way to configure git merge in such a way that conflict resolution always goes through an external merge tool?

我正在为语义合并编写配置,有些情况是git错误处理的,但可以通过语义合并正确解决: *两名开发人员在同一文件的两个不同位置添加了相同的方法.

I'm writing the configuration for semanticmerge and there are cases like this that are incorrectly handled by git but can be correctly solved by semanticmerge: * two developers added the same method on two different locations of the same file.

问题在于git merge表示冲突是自动的,因此无法调用git mergetool.

The problem is that git merge says the conflict is automatic so git mergetool can't be invoked.

谢谢.

推荐答案

请参见 gitattributes .深入了解的是一个称为合并"的属性 设置用于匹配文件的合并方法.

See the documentation of gitattributes. Deep down is an attribute called, "merge" that sets the merge method for matching files.

例如,这样,您可以在包含以下内容的项目的根目录中有一个.gitattributes文件,

As such, for example, you could have a .gitattributes file in the root of the project that contains,

*.fancy merge filfre %O %A %B %L %P

,它将使用filfre程序进行合并.它使用

which will use the filfre program to merge. It calls the program with

  • %O祖先的版本临时文件名
  • %A当前版本的文件名
  • %B其他分支的版本临时文件名
  • %L冲突标记大小
  • 将存储合并结果的%P路径名

合并驱动程序应使用合并中的合并结果覆盖%A.

The merge driver is expected to overwrite %A with the result of the merge in the merge.

该文档中有一节以定义自定义合并驱动程序"为标题,建议用于全局设置合并工具

There is a section in that documentation, headed by "Defining a custom merge driver," that suggests, for globally setting the merge tool

[merge "filfre"]
    name = feel-free merge driver
    driver = filfre %O %A %B %L %P
    recursive = binary

放置在您的git配置中,例如.git/config$HOME/.gitconfig.

placed in your git configuration, for example, .git/config or $HOME/.gitconfig.

这篇关于有没有一种方法可以强制git merge始终使用外部合并工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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