Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Configuring multiple external diff tools based on extension?


I have multiple different binary filetypes that require different programs to diff and merge. I would like to be able to launch the proper diff program when right-clicking a file and selecting `External Diff`.

I already have all the different difftools and mergetools setup in my global config like so:


# Differencing Configuration
tool = WinMerge
[difftool "WinMerge"]
cmd = \"C:\\Program Files\\WinMerge\\WinMergeU.exe\" -e -u -dl \"Old $BASE\" -dr \"New $BASE\" \"$LOCAL\" \"$REMOTE\"
trustExitCode = true
[difftool "sourcetree"]
cmd = '' \"$LOCAL\" \"$REMOTE\"
[difftool "LogixCompare"]
cmd = \"C:\\Program Files (x86)\\Rockwell Software\\Logix Designer Tools\\Logix Designer Compare Tool\\RSLCompare.exe\" \"$LOCAL\" \"$REMOTE\" -PM FastestCompare


I also setup the extensions in gitattributes like `*.acd binary diff=LogixCompare`, but doing an external diff on such a file still just opens WinMerge (my default difftool as shown above).

EDIT: I now know that gitattributes only launches a diff driver which is different from a difftool. I guess the best I can hope for is a new feature in SourceTree that would allow us to select one of the configured difftools as an "advanced" External Diff. `git difftool --tool-help` will list the available built-in and user configured tools, so maybe SourceTree can use that to populate the list or directly read them from the global config file?


3 answers

1 accepted

0 votes
Answer accepted
Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Jun 04, 2019

Hello! Sourcetree doesn't currently support this feature, but we appreciate the suggestion!


However, that doesn't mean it's impossible to accomplish this. You can use the "Custom Difftool" setting to point to a script you've created to allow custom diff tools to launch depending on the file type. You can find the logic for this idea here. Just be sure to configure ST to point to that script.

I had to do some playing around to actually get the path formatting and everything to work on Windows. This is my difftool entry:

[difftool "ExtSelector"]
cmd = \"C:\\Program Files\\Git\\\" \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\"

And this is the contents of that script that finally didn't complain about paths and succeeded every time:




shopt -s nocasematch
case "${EXTENSION,,}" in
C:/Program\ Files\ \(x86\)/Rockwell\ Software/Logix\ Designer\ Tools/Logix\ Designer\ Compare\ Tool/RSLCompare.exe $LOCAL $REMOTE -PM FastestCompare
C:/Program\ Files/WinMerge/WinMergeU.exe -e -u -dl Local -dm Base -dr Remote $LOCAL $BASE $REMOTE -o $MERGED

exit $?

 Note that I pass the file path variables already quoted, so they are unquoted when used in the script. I went ahead and passed all three file versions to Winmerge, so most would probably pair that down to just Local and Remote.

Mike Corsaro
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Jun 21, 2019

Nice work! Thanks for sharing your solution!

Is this feature (use external diff tools based on extension) meanwhile implemented in Sourcetree?

I made following entry in the gitconfig

[difftool "vw7diff"]
cmd = 'C:/Program Files (x86)/INOSOFT GmbH/VisiWin 7/Development/bin/VisiWin7.ProjectCompare.exe' -c \"$LOCAL\" \"$REMOTE\"

 And added following in the gitattributes

*.vw7 diff=vw7diff

But when I rightclick on the .vw7 file in sourcetree to start the external diff nothing happens.

When I enter following command in git bash it works. So is there any fault in the entry in my gitattributes?

git difftool -t vw7diff -y -- HMI/HmiServer/HmiServer.vw7 

gitattributes doesn't let you set the difftool for different filetypes (it should and I've made that request with the git team). You have to setup your difftool to be a script like I did in my follow-up post in this thread.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events