Configuring WinMerge as the Git Diff Tool on Windows
Why use WinMerge#
- It's free and open source (unlike Beyond Compare, which costs $12 per year)
- It's really useful (much better than the built-in git diff)
- It looks good too (?)
How to install WinMerge in git#
- Go to the official repository and download the WinMerge version that corresponds to your operating system. Install it with the default settings.
- Find the git configuration file
.gitconfig
. For Windows users, it's usually located in the user folderC:\Users\%username%
. If you're using a different system, then sorry, this guide is for WinMerge (just kidding). - Add the following configuration to the file:
[diff]
tool = winmerge
[difftool "winmerge"]
cmd = "'C:/Program Files (x86)/WinMerge/WinMergeU.exe'" -e "$LOCAL" "$REMOTE"
[difftool]
prompt = false
[merge]
tool = winmerge
[mergetool "winmerge"]
cmd = "/c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe" -u -e -wl -wr $LOCAL $BASE $REMOTE -o $MERGED
[mergetool]
keepBackup = true
trustExitCode =true
Usage#
To compare differences:
git difftool <file_name>
To merge conflicts:
git mergetool
Simplify Commands#
If you find the commands too long and inefficient during actual usage, you can set up aliases for them.
git config --global alias.dft difftool
git config --global alias.mgt mergetool
For example, I've configured difftool
and mergetool
as dft
and mgt
aliases, respectively. You can use them directly like this:
git dft
git mgt
References#
Use WinMerge inside of Git to file diff
Configuring Beyond Compare as the Git Diff Tool on Windows
Using WinMerge as the Git Diff/Merge Tool on Windows 64-bit