Search code examples
windowsgitdiffmerge

Git configure difftool and mergetool by DiffMerge not working


I'm trying to configure DiffMerge for git to use for difftool and mergetool. I used following command:-

The following commands in a Command Prompt window will update your .gitconfig to configure GIT use DiffMerge:

  C:\> git config --global diff.tool diffmerge

 C:\> git config --global difftool.diffmerge.cmd

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

If I check the content of .gitconfig it has following:-

   ` [diff]
        tool = diffmerge
    [mergetool "diffmerge"]
        cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe -merge -result=\"\" \"\" \"\" \"\"
        trustExitCode = true
    [merge]
        tool = diffmerge
    [difftool "diffmerge"]
        cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe \"\" \"\"
    [core]
        autocrlf = true
        excludesfile = C:\\Users\\dev\\Documents\\gitignore_global.txt
    [user]
        name = DESKTOP - VAFJEG6\\dev
          email = [email protected] `

If I try $ git config --global --list:-

  diff.tool=diffmerge
  mergetool.diffmerge.cmd=C:/Program\ 
  Files/SourceGear/Common/DiffMerge/sgdm.exe -merge -result="" "" "" ""
  mergetool.diffmerge.trustexitcode=true
  merge.tool=diffmerge
  difftool.diffmerge.cmd=C:/Program\ 
  Files/SourceGear/Common/DiffMerge/sgdm.exe "" ""
  core.autocrlf=true
  core.excludesfile=C:\Users\dev\Documents\gitignore_global.txt
  user.name=DESKTOP-VAFJEG6\dev
  [email protected]`

If I try git $ git difftool it showed this dialog:-

enter image description here

What is wrong? How to configure it correctly?


Solution

  • The $LOCAL/$REMOTE mentioned in the doc must have been interpreted by the shell (if typed from a git bash instead of a CMD session) and replaced by "".

    Edit directly the global config (git config --global --edit) and add the missing elements to obtain:

     [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="$PWD/$MERGED" "$PWD/$LOCAL" "$PWD/$BASE" "$PWD/$REMOTE"
         trustExitCode = true