gitvisual-studiowinmerge

How do I tell Visual Studio to use WinMerge with Git?


I'm using Git with VS2017 Enterprise, and if I right-click a file in Changes and choose "Compare with unmodified" it opens in a new window in VS using the VS diff tool.

I would like to use WinMerge instead, and have been looking at resources such as this (instructions for BeyondCompare, but the principle should be the same), this (ditto for GitExtensions) and this, but cannot get it to work. Whatever I do, I still get the VS diff tool in VS.

The .gitconfig file in my user folder looks like this...

[user]
  name = Me
  email = myemail@somewhere.jim
[core]
  autocrlf = true
[diff]
  tool = winmerge
[difftool "winmerge"]
  cmd = "'C:/Program Files (x86)/WinMerge/WinMergeU.exe'" -e "$LOCAL" "$REMOTE"

...and the .git/config file in my project folder looks like this (sensitive info changed)...

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[user]
[diff]
    tool = winmerge
[difftool]
    prompt = true
[difftool "winmerge"]
    cmd = "/c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe" -u -e $LOCAL $REMOTE
    keepBackup = false
[merge]
    tool = vsdiffmerge
[mergetool]
    prompt = true
[remote "origin"]
    url = https://me@dev.azure.com/me/Project/_git/Project
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[gui]
    wmstate = normal
    geometry = 1346x938+75+75 445 196

Anyone able to tell me what I need to do to use WinMerge?


Solution

  • Your problem is that...

    /c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe
    

    ...is an incorrect path. If you look in your first code snippet, you'll see the correct path, however this is overridden by the project's config file.

    If you change the path in the second snippet, or (better still) remove that whole section, as it only duplicates what's in the first, then you should find it will work.