Search code examples
gitversion-controlgit-mergegit-diffgit-config

How to set difftool/mergetool for a specific file extension in Git?


Is it possible to set a custom tool for merging files with a specific extension in Git?

Thanks for any pointers!

Update

I wasn't able to come up with any better solution than defining a custom difftool and calling it by hand as @jarodeells suggested:

[diff]
    tool = mydiff
[difftool "mydiff"]
    cmd="script.sh \"$LOCAL\" \"$REMOTE\""

Then calling it explicitly:

$ git difftool -t mydiff someFileWith.ext

Solution

  • If not already supported, install a shell script that keys off the extension and calls the correct merge tool.