代码之家  ›  专栏  ›  技术社区  ›  tigrou

有没有一种方法可以指定一个自定义工具,让git在进行合并时始终使用?

  •  0
  • tigrou  · 技术社区  · 4 年前

    在我的一个项目中,我有一些具有特定扩展名的文件,我想使用我自己的特定工具而不是git本身进行合并。

    我知道可以在中指定自定义合并和差异工具 .gitconfig 这种方式:

    [difftool "sourcetree"]
        cmd = 'C:/somepath/difftool.exe' \"$LOCAL\" \"$REMOTE\"
    [mergetool "sourcetree"]
        cmd = 'C:/somepath/difftool.exe' \"$BASE\" \"$LOCAL\" \"$REMOTE\" -o \"$MERGED\"
    

    该合并工具将自动调用以解决冲突。 但是(除非我错过了什么)git会首先尝试自己合并文件。问题是git会尝试将这些文件合并为常规文本文件(例如:代码),可能会忽略存在冲突的事实,或者认为存在冲突而实际上没有冲突。

    $ git merge foo
    Auto-merging somefile //custom mergetool not called :(
    CONFLICT (content): Merge conflict in index.html
    Automatic merge failed; fix conflicts and then commit the result.
    

    我希望我的合并工具在必须合并文件时始终被调用(而无需git自动尝试合并)。这可能吗?

    0 回复  |  直到 4 年前