May 4, 2010

External merge-diff - Git on windows

To configure and use Git in a Linux environment is quite easy, but if you are working in a Windows system, things get a little bit complicated.

I use MsysGit which is a great port to win32, and as a merge/diff tool I use WinMerge (I can't stand KDiff); to work with WinMerge as 'difftool' and 'mergetool' you could do this:

- First, create a wrapper script for our 'difftool', save this file as 'diff-tool.sh' in your $HOME folder:

#!/bin/sh
# Change "E:/bin/WinMerge/WinMergeU.exe" with your winmerge path
"E:/bin/WinMerge/WinMergeU.exe" -e -ub "$1" "$2" | cat

- Now, edit your $HOME/.gitconfig file, you can take as example my current configuration:
[core] 
autocrlf = false 

[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

[user]
name = Timoteo Ponce
email = timo.slack@gmail.com

[merge]
tool = winmerge

[mergetool "winmerge"]
cmd = "E:/bin/WinMerge/WinMergeU.exe" "$MERGED"
keepBackup = false

[diff]
tool = winmerge

[difftool "winmerge"]
cmd = $HOME/diffmerge-tool.sh "$LOCAL" "$REMOTE"