How to add Devart's Code Compare as custom diff & merge tool within Sourcetree?
-
I take it `Code Compare` is not one of the built-in options for setting an external merge tool the way `Beyond Compare` is. – Philip Pittle Aug 12 '15 at 18:06
5 Answers
I modified my C:\Users\[User Name]\.gitconfig
file by adding this like Alex suggested:
[difftool "codecompare"]
cmd = 'C:\\Program Files\\Devart\\Code Compare\\codecompare.exe' -W \"$LOCAL\" \"$REMOTE\"
renames = true
[diff]
tool = codecompare
guitool = codecompare
[mergetool "codecompare"]
cmd = 'C:\\Program Files\\Devart\\Code Compare\\codemerge.exe' -MF=\"$LOCAL\" -TF=\"$REMOTE\" -BF=\"$BASE\" -RF=\"$MERGED\"
trustExitCode = true
[mergetool]
keepBackup = false
[merge]
tool = codecompare
guitool = codecompare
Then I changed my SourceTree Tools -> Options -> Diff
to System Default.
After that my Code Compare
started running correctly inside Visual Studio which is awesome.
Hope it helps!

- 42,814
- 35
- 154
- 218
In SourceTree open Tools > Options > Tab: Diff.
On panel External Diff / Merge put the following data:
External Diff Tool: Custom
Diff Command: C:/Program Files/Devart/Code Compare/CodeCompare.exe
Arguments: $LOCAL $REMOTE
Merge Tool: Custom
Merge Command: C:/Program Files/Devart/Code Compare/CodeMerge.exe
Arguments:-MF "$LOCAL" -TF "$REMOTE" -BF "$BASE" -RF "$MERGED"

- 7,195
- 6
- 56
- 107

- 2,594
- 2
- 28
- 32
-
1I have not delved into it but according to Devart it should be `-W "$LOCAL" "$REMOTE"` for CodeCompare.exe – LosManos May 22 '17 at 11:04
-
LosManos is right... it should have a -W in front of the "Diff Command" arguments. – Ph0t0n May 09 '18 at 22:40
To integrate Code Compare with Sourcetree add the following lines to the c:\Users\[User Name]\.gitconfig
file:
[difftool "codecompare"]
cmd = 'C:\\Program Files\\Devart\\Code Compare\\codecompare.exe' -W \"$LOCAL\" \"$REMOTE\"
renames = true
[diff]
tool = codecompare
guitool = codecompare
[mergetool "codecompare"]
cmd = 'C:\\Program Files\\Devart\\Code Compare\\codemerge.exe' -MF=\"$LOCAL\" -TF=\"$REMOTE\" -BF=\"$BASE\" -RF=\"$MERGED\"
trustExitCode = true
[mergetool]
keepBackup = false
[merge]
tool = codecompare
guitool = codecompare
Now git difftool will work properly from both command line and Sourcetree.
Note: you need select 'System Default' option in Sourcetree options.

- 2,594
- 2
- 28
- 32
-
1Couldn't get this working until I saw your note about setting Sourcetree's option to "System Default", thanks. – Polshgiant Feb 27 '16 at 01:23
What worked for me: Win10, SourceTree 2.1.110, Code Compare 4.2.236
- SourceTree>Tools>Options>External Diff
- Diff: Tool->Custom;
- Command:
c:\Program Files\Devart\Code Compare\CodeCompare.exe
- Arg:
$LOCAL $REMOTE
- Command:
- Merge: Tool->Custom
- Command:
c:\Program Files\Devart\Code Compare\CodeMerge.exe
- Arg:
-MF=\"$LOCAL\" -TF=\"$REMOTE\" -BF=\"$BASE\" -RF=\"$MERGED\"
- Command:
Keep in mind that 3-way merge is only available at Code-Compare PRO
https://www.devart.com/codecompare/featurematrix.html

- 1,310
- 13
- 12
Check Devart Code Compare help file section on 'Version Control System Integration'. There is a topic for GIT.

- 9
-
4While this may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. – jean Mar 05 '15 at 14:32