When running git mergetool
, I'd like to have git select the merge tool used based on the file extension. How can I do this?
A similar question was asked here: Git: configure patterns for difftool and mergetool
and the answer was to write a custom merge driver. However, it seems like this would be executed upon git merge
, whereas I would like the merge tool to be chosen upon git mergetool
.
It seems like there must be some way to specify this with .gitattributes, but I can't seem to figure out how. Any advice?
One solution (since my old answer isn't a good fit for mergetool
) is to set as a mergetool
a wrapper script.
git config --global merge.tool customMergeTool
git config --global mergetool.customMergeTool.cmd 'customMergeTool.sh \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"'
That wrapper script customMergeTool.sh
would:
$BASE
is (in particular, its file extension)mergetool
Here is for instance the script that the OP elsevers came up with: merge-wrapper
.
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