Why can't I configure an external difftool or mergetool for Git?

1k Views Asked by At

I'm trying to configure an external difftool and mergetool for Git under Windows 10.

Everything keeps telling me to type out two Git commands like the ones below. Some say to use a wrapper.sh while others say it's not necessary.

git config --global diff.tool diffmerge

(The second line looks something like this:)

git config --global difftool.diffmerge.cmd "path to sgdm.exe or some_wrapper.sh" $LOCAL $REMOTE**

This doesn't work for me. I've also tried:

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

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

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

My config file looks like this:

[filter "lfs"]

        clean = git-lfs clean %f
        smudge = git-lfs smudge %f
        required = true
[user]

        name= John Doe
[diff]

        tool = dm
[difftool]

        prompt = true
[difftool "dm"]

        cmd = \"C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe\" \"$LOCAL\" \"$REMOTE\" //t

What am I doing wrong?

2

There are 2 best solutions below

0
Ashley Coolman On BEST ANSWER

It sounds like you might be happy with a full GUI client. I have used Sourcetree to integrate with external merge tools (on OSX). And infact, Sourcetree's in-built merge tool is great too.

1
hsirah On

Check your global .gitconfig file to make sure that the paths ended up in the correct format (with quotes around paths with spaces etc).

Here is my relevant section from my config file:

[diff]
    tool = vsdiffmerge
[difftool]
    prompt = true
[difftool "vsdiffmerge"]
    cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\vsdiffmerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
    keepbackup = false
    trustexistcode = true
[merge]
    tool = vsdiffmerge
[mergetool]
    prompt = true
[mergetool "vsdiffmerge"]
    cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\vsdiffmerge.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" //m
    keepbackup = false
    trustexistcode = true