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

6

12

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.

Scimitar answered 13/12, 2012 at 20:36 Comment(0)
U
14

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

Unexperienced answered 13/12, 2012 at 20:55 Comment(2)
Thanks for the answer. However, I'm still getting the same behavior -- nothing launches, no error, nothing. I'm using msysgit 1.8 if that matters.Scimitar
Interesting. I'm using 1.7.10.msysgit.1. I'll try to upgrade later to see if that's the difference.Unexperienced
N
8

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"'
Nim answered 18/4, 2018 at 14:48 Comment(0)
S
5

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
Spinney answered 20/3, 2013 at 19:34 Comment(0)
F
2

This worked for me:

C:\> git config --global diff.tool diffmerge
C:\> git config --global difftool.diffmerge.cmd
    "C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe
        \"$LOCAL\" \"$REMOTE\""

C:\> git config --global merge.tool diffmerge
C:\> git config --global mergetool.diffmerge.trustExitCode true
C:\> git config --global mergetool.diffmerge.cmd 
    "C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe
        /merge /result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\""
Freiman answered 25/2, 2014 at 10:36 Comment(0)
P
0

This configuration works for me with Git 1.7.9 and Windows 7 64 bit. My starting point is the Pro Git book http://git-scm.com/book/en/Customizing-Git-Git-Configuration. The changes for Windows vs Mac were a) for diff, just replacing / with \\ and putting quotes round the path containing a space b) for merge the parameters are the same as yours but with quotes. Thus:

.gitconfig

[merge]
     tool = extMerge
[mergetool "extMerge"]
    cmd = extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
    trustExitCode = false
[diff]
    external = extDiff

Two script files that are on your PATH

extMerge

#!/bin/sh
"C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe" "-merge" "-result=$4" "$2" "$1" "$3"

extDiff

#!/bin/sh
[ $# -eq 7 ] && "C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe" "$2" "$5"
Philoprogenitive answered 30/1, 2013 at 13:30 Comment(0)
H
0

This one did it for me when none of the other's did:

[core]
    autocrlf = false
[user]
    email = XYZ
    name = ABC
[merge]
    tool = diffmerge
[mergetool "diffmerge"]
    trustExitCode = true
    cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe --merge --result=$MERGED $LOCAL $BASE $REMOTE
[mergetool]
    keepBackup = false
[difftool "diffmerge"]
    cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe \"$LOCAL\" \"$REMOTE\"
[diff]
    tool = diffmerge
[push]
    default = matching
Hamilton answered 31/10, 2014 at 15:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.