Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

diffmerge

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.

like image 950
David Hoerster Avatar asked Dec 13 '12 20:12

David Hoerster


3 Answers

following worked for me-

git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd 'C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe "$LOCAL" "$REMOTE"'
git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.trustExitCode true
git config --global mergetool.diffmerge.cmd 'C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe -merge -result="$MERGED" "$LOCAL" "$BASE" "$REMOTE"'
like image 104
Snehal Indurkar Avatar answered Nov 10 '22 22:11

Snehal Indurkar


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.)

like image 13
Edward Thomson Avatar answered Nov 10 '22 22:11

Edward Thomson


This has worked well for me for quite a while. (Windows 7, latest version of Git.)

Make sure sgdm.exe is in the environment path.

[diff]
    tool = sgdm
[difftool "diffmerge"]
    cmd = sgdm $LOCAL $REMOTE
[merge]
    tool = sgdm
[mergetool "diffmerge"]
    cmd = sgdm --merge --result=$MERGED $LOCAL $BASE $REMOTE
    trustexitcode = false
[difftool "sgdm"]
    cmd = sgdm $LOCAL $REMOTE
[mergetool "sgdm"]
    trustexitcode = false
    cmd = sgdm --merge --result=$MERGED $LOCAL $MERGED $REMOTE --title1=Mine --title2='Merged: $MERGED' --title3=Theirs
like image 5
John Fisher Avatar answered Nov 10 '22 22:11

John Fisher