How to get DiffMerge configured to work with Git on Windows 7 or Windows 2012?

David Hoerster picture David Hoerster · Dec 13, 2012 · Viewed 9.9k times · Source

So I've seen a few questions about getting DiffMerge to be the mergetool and difftool for git. Essentially it comes down to having DiffMerge (sgdm.exe) in your PATH and a .gitconfig that looks like:

[diff]
    tool = DiffMerge
[difftool "DiffMerge"]
    cmd = 'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe' "$LOCAL" "$REMOTE"
[merge]
    tool = DiffMerge
[mergetool "DiffMerge"]
    cmd = 'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe' -merge -result="$MERGED" "$LOCAL" "$BASE" "$REMOTE"
    trustExitCode = true
    keepBackup = false

When I run git difftool file1 file2, nothing happens. No error code, no launching of DiffMerge. From Git Bash and a Windows Command Line, I can run sgdm file1 file2 and DiffMerge comes up.

I've modified the cmd in the .gitconfig to not have a path or extensions (e.g. sgdm only), but still to no avail.

Has anyone encountered this? Are there some obvious things I'm missing? I feel like I'm missing something obvious.

Answer

Edward Thomson picture Edward Thomson · Dec 13, 2012

My .gitconfig for using SourceGear DiffMerge is:

[mergetool "diffmerge"]
cmd = \"C:\\program files\\sourcegear\\common\\diffmerge\\sgdm.exe\" --merge --result=$MERGED $LOCAL $BASE $REMOTE

(Obviously, flip $LOCAL and $REMOTE if you prefer them on the other side.)