Skip to content

Instantly share code, notes, and snippets.

@shawndumas
Created August 5, 2013 19:08
Show Gist options
  • Save shawndumas/6158524 to your computer and use it in GitHub Desktop.
Save shawndumas/6158524 to your computer and use it in GitHub Desktop.
Using WinMerge as the git Diff/Merge Tool on Windows 64bit
[mergetool]
prompt = false
keepBackup = false
keepTemporaries = false
[merge]
tool = winmerge
[mergetool "winmerge"]
name = WinMerge
trustExitCode = true
cmd = "/c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe" -u -e -dl \"Local\" -dr \"Remote\" $LOCAL $REMOTE $MERGED
[diff]
tool = winmerge
[difftool "winmerge"]
name = WinMerge
trustExitCode = true
cmd = "/c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe" -u -e $LOCAL $REMOTE
@mrnams
Copy link

mrnams commented Feb 12, 2022

Neither cmd = "C:\Program Files (x86)\WinMerge\WinMergeU.exe" nor
cmd = "/c/Program\ Files\ \(x86\)/WinMerge/WinMergeU.exe" worked for me.
It always show Visual Studio Diff tool and open in visual studio itself?

@Skrell
Copy link

Skrell commented Feb 23, 2023

Searched the entire internet, this is the ONLY solution that worked 100%!!!!

@john-j-mclaughlin
Copy link

Neither cmd = "C:\Program Files (x86)\WinMerge\WinMergeU.exe" nor
cmd = "/c/Program\ Files\ (x86)/WinMerge/WinMergeU.exe" worked for me.
It always show Visual Studio Diff tool and open in visual studio itself?

I didn't try either, but from working with mixed-style path configs a lot in the past I would suggest:

cmd = "C:\Program Files (x86)\WinMerge\WinMergeU.exe" (Windows style)
(double backslashes (i,e, escape the backslashes) since it's in a quoted string),
OR
cmd = "/c/Program Files (x86)/WinMerge/WinMergeU.exe" (POSIX style)
(no escaping special chars (space, parens) since it's in a quoted string).

I deal with this a lot since BASH is the only command shell I use on Windows.

@asmwarrior
Copy link

asmwarrior commented May 15, 2023

Thanks to the author, but I suggest this set of options for mergetool/cmd: -u -e -fm -wl -dl "Local" -wr -dr "Remote" $LOCAL $MERGED $REMOTE This way MERGED file is in the middle pane, so you can apply changes directly from LOCAL or REMOTE. Additionally, LOCAL and REMOTE are marked "read only"

Hi, mrsteklo, thanks.

I just tried, and I think your method is correct, thanks!

When I see in the middle panel, there are many ">>>>>> or <<<<<<<" like text, is that correct?
Do I need to manually "copy right to middle" or "copy left to middle" to solve such conflict?

Thanks!

@asmwarrior
Copy link

Warning: This is right for diffs, but this will burn you if you use it for merges! I used this and had to redo my merge changes.

Use mrsteklo's version of the options above, or alternatively:

cmd = "/c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe" -u -e -wl -wr $LOCAL $BASE $REMOTE -o $MERGED

@christopherliu I think this method is not correct. Especially that you use the $BASE. This is because in this case, the base code is shown in the middle panel, the base code is normally the common ancestor commit of the both two git branches, and you have to manually add many changes from both the left(local) and right(remote) commits.

I would suggest you could use $MERGED, this is already generated file by git, and some parts of the changes are already merged without any conflict, it it see a conflict, git will put something like <<<<<<<<< and >>>>>>>> in the $MERGED, so that you can edit the conflict part.

@mrnams
Copy link

mrnams commented Mar 21, 2024

Finally this worked for me

[mergetool "winmerge"]
name = WinMerge
trustExitCode = true
cmd = ""C:/Program Files (x86)/WinMerge/WinMergeU.exe" "$LOCAL" "$REMOTE" "$MERGED" >/dev/null 2>&1"

[diff]
tool = winmerge
[difftool "winmerge"]
name = WinMerge
trustExitCode = true
cmd = ""C:/Program Files (x86)/WinMerge/WinMergeU.exe" "$REMOTE" "$LOCAL" >/dev/null 2>&1"

command to diff
"git difftool"
and from winmerge I manually merge with winmerge functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment