Git + WinMerge + Cygwin





0/5 (0 vote)
How to use WinMerge to view diffs with Git under Cygwin
Background
This took me a good half day to figure out so I thought it'd be useful to others in a similar situation. It's derived from this post on StackOverflow[^]. You can find more details there but I did have to make a few changes to get it fully working both under Cygwin and a plain Windows command prompt. Last I checked this was working under:- Git 1.7.0.4
- WinMerge 2.12.4.0
- Cygwin 1.7.5
- Windows 7 x64
Tying WinMerge to Git
-
Add the following lines to your .gitconfig file:
[diff] tool = winmerge [difftool "winmerge"] cmd = git-difftool-winmerge-wrapper.sh \"$LOCAL\" \"$REMOTE\" [difftool] prompt = false
The last option (prompt = false) is optional. You can omit it if you do want Git to prompt you before opening each diff. - Create a file named git-difftool-winmerge-wrapper.sh and place it in your path. I just dropped it in my home directory. You can change the default Cygwin path to include your home directory by modifying the .bash_profile file (also in your home directory) and adding PATH=${PATH}:${HOME}
-
Add the following to git-difftool-winmerge-wrapper.sh:
#!/bin/sh echo "Launching WinMergeU.exe \"$(cygpath -aw "$1")\" \"$(cygpath -aw "$2")\"" if [ -f $1 -a -f $2 ] then "C:/Program Files (x86)/WinMerge/WinMergeU.exe" -e -u -wl -dl "Base" -dr "Mine" "$(cygpath -aw "$1")" "$(cygpath -aw "$2")" else echo "skipping as one file doesn't exist" fi
Obviously, you may need to adjust the WinMerge installation folder to your local install path.
Running under Cygwin
Just run git difftool.Running under Windows command prompt
Ensure you have all necessary files in your path:- Git binaries
- git-difftool-winmerge-wrapper.sh
- WinMerge executable