This project is read-only.

Setting Up Git with DiffMerge

Feb 12, 2013 at 8:09 PM
Edited Feb 12, 2013 at 9:49 PM
These are the steps I took to set 'DiffMerge.exe' as my 'Diff Tool' for both the 'Git Source Control Provider' in Visual Studio, and in 'Git for windows'.
This configuration lets me view a diff in:
  • In Visual Studio, from the 'Git Pending Changes' window
  • GIT-GUI, from the 'Tools' menu
  • gitbash, on the command line

DiffMerge in VS

This is easy.
  • Click 'Tools' | 'Options' menu
  • Select the 'Source Control' | 'Git Source Control Provider Options' category
  • Set the 'Path to external Diff Tool' to the actual full path of DiffMerge (sgdm.exe). In my case it was 'C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe'

DiffMerge in GitBash/GitGui

This is much harder. It has been a long journey finding an answer that works.
  • Edit (or create) ".gitconfig" (just an extension, no file name), it is usually found in '%USERPROFILE%' (on Windows 7 at least)
    tool = diffmerge
[difftool "diffmerge"]
    cmd = "C:/PROGRA~1/SourceGear/Common/DiffMerge/sgdm.exe $LOCAL $REMOTE"
    prompt = false

    tool = diffmerge
[mergetool "diffmerge"]
    cmd = "C:/PROGRA~1/SourceGear/Common/DiffMerge/sgdm.exe --merge --result=$MERGED $LOCAL $BASE $REMOTE" 
    trustExitCode = false
    keepBackup = false

[guitool "DiffMerge"]
    cmd = git difftool -y $FILENAME
    noconsole = yes
    needsfile = yes
Notice that paths contain forward slashes, not backslashes.
Notice that you need to use the DOS 8.3 paths to avoid spaces in the directories.

Now you can issue commands in GitBash like:
git difftool
And you have a tool in GIT-GUI (Tools menu) for doing a DiffMerge on a changed file.