Code Compare Integration with GIT

While working with Git, we often need some powerful on-the-fly diff and merge capabilities. For example, to resolve merge conflicts, compare various instances of the Git config file, diff code side by side and edit it quickly and efficiently. While Git itself does not provide this functionality, you can use external diff and merge tools. Here, you'll learn how to integrate external tools with Git. In this particular example, we'll use Code Compare as the tool of choice.

To use Code Compare with Git, you need to add the following lines to the gitconfig file:

[difftool "codecompare"]
cmd = 'C:\\Program Files\\Devart\\Code Compare\\codecompare.exe' -W \"$LOCAL\" \"$REMOTE\" 
renames = true

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
keepBackup = false
tool = codecompare
guitool = codecompare

Note: The global gitconfig file is located in C:\Users\MyLogin\.gitconfig. The config file for a local repository is located in repository root in the ".git" folder (this folder is hidden by default).