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
git mergetool allows you to use a GUI merge program (i.e. Meld) to resolve the merge conflicts that have occurred during a merge. Like difftool you can set the GUI program on the command line using -t <tool> / --tool=<tool> but, as before, it makes more sense to configure it in your . gitconfig file.
Usage. Run Git Difftool: Diff File from the Command Palette or use ⌥⌃D to diff the currently open file. Run Git Difftool: Diff Project from the Command Palette or use ⌃⇧D to diff the whole project.
Update: See @Ackdari comments below. The external tool doesn't have to be command-line based. I'm not sure how git uses binary = True
when an external tool is used, but I suspect it might be needed for all flows to work.
If your external diff tool* is command-line only (no GUI), You can use the built-in gitattributes
for this:
in .gitconfig
add:
[diff "my_diff"]
command = Tools/csv_diff
binary = true # Not sure this is required.
and in .gitattributes
(either global or per repository, see here) add:
*.csv diff=my_diff
[*] The command for the external diff tool will be called by git with the 7 parameters detailed under GIT_EXTERNAL_DIFF in the manual here.
If not already supported, install a shell script that keys off the extension and calls the correct merge tool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With