Last Updated: September 27, 2021
· henriqueso

WinMerge as git difftool on Windows

In case you're looking for a way to use WinMerge as your git difftool on Windows, this tip may be helpful.

In fact, it's simple to resolve and is also a silly problem but it took me a good amount of time just because of the path where WinMerge was installed at C:\Program Files (x86)\winmerge\winmergeu.exe

Not surprisingly, I faced problems with characters like the parenthesis(. And that's ok. We know we can put it between double quotes " ". But it took me a while to get it right as I wanted.

Browsing over the web you will find many ways of doing this. The way that worked pretty well for me is this one:

1) Open .gitconfig file. It's located at your home directory: c:\users\username\.gitconfig

2) Add the lines below. Pay attention to the single quotes wrapping the path to winmerge:

    tool = winmerge
[difftool "winmerge"]
    cmd = "'C:/Program Files (x86)/WinMerge/WinMergeU.exe'" -e "$LOCAL" "$REMOTE"

You can pass other parameters to WinMerge if you want. Follow the whole discussion here:

[Edited] For those wondering how to use the command, here is an example:<br />
git difftool HEAD HEAD~1

Related protips:

Force a "git stash pop"

4 Responses
Add your response

Hello, what do you have in $LOCAL and $REMOTE ?

over 1 year ago ·

That is exactly the line I have in my .gitconfig. They are placeholders for WinMerge parameters. Then you may call like that:

git difftool

It'll open on WinMerge comparing your local version with the baseline.

over 1 year ago ·

Thanks for sharing!

over 1 year ago ·
[difftool "WinMerge"]
    cmd = \"C:\\Program Files\\WinMerge\\WinMergeU.exe\" -e -u -dl \"Old $BASE\" -dr \"New $BASE\" \"$LOCAL\" \"$REMOTE\"
    trustExitCode = true

[mergetool "WinMerge"]
    cmd = \"C:\\Program Files\\WinMerge\\WinMergeU.exe\" -e -u -dl \"Local\" -dm \"Base\" -dr \"Remote\" \"$LOCAL\" \"$BASE\" \"$REMOTE\" -o \"$MERGED\"
    trustExitCode = true
    keepBackup = false
over 1 year ago ·