Tuesday, March 30, 2010

Merging! Git thee behind me!

Okay, obviously I like Git enough to be talking about it. However there is one thing that I hate about Git. It's GUI tools are ugly. Seriously, seriously, eyes-bleedingly ugly. And this I don't understand. For love of Mike, git is the official CM system for Qt, the goto GUI api people. I ask the interwebs: can some happy Qt guru make a lovely Git GUI? Please? Really.

In the meantime, probably the first this you'll want to do after installing Git is to set up your merge and diff tools of choice. At least diff-ing will look the way you want it to.

You might this this is easy. You'd be wrong. I have seen several different approaches to setting up external diff tools, some of which require shell script indirection. After a lot of plonking on the keyboard here is the solution that I came up with. Disclaimer: I am running msysgit on windows xp 32bit.

I got both the diff and merge tools working with BeyondCompare3 (bc3), kdiff3, and diffmerge. To these, in either your repository config file or you global .gitconfig file add the following:
[mergetool "kdiff3"]
path = C:/Program Files/KDiff3/kdiff3.exe
[mergetool "diffmerge"]
  cmd = "\"c:/program files/SourceGear/DiffMerge/DiffMerge.exe\" \"$LOCAL\" \"$BASE\" \"$REMOTE\" -result=\"$MERGED\""
prompt = false
[mergetool "bc3"]
  cmd = "\"c:/program files/beyond compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""
prompt = false
[difftool "kdiff3"]
path = /C/"Program Files"/KDiff3/kdiff3.exe
[difftool "diffmerge"]
  cmd = "\"c:/program files/SourceGear/DiffMerge/DiffMerge.exe\" \"$LOCAL\" \"$REMOTE\""
prompt = false
[difftool "bc3"]
  cmd = "\"c:/program files/beyond compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\""
prompt = false
Of course you will want to fix the paths to point to the correct place for your machine.

Once this is done you can set which tool is used as default with:
git config diff.tool=bc3
git config merge.tool=diffmerge

And there you go.

1 comment:

  1. Ugh. I'm sticking to SVN/Tortoise for now.

    SVN has the same no-checkout model of development which I love for the same reasons you like them in git but it does use a central repository. Your local working copy is still 2x as big as the repository because SVN keeps the unmodified files locally so you don't need to hit the server for minor diffs, but you don't have the entire repository with history on every workstation. Tortoise also offers great Windows Explorer integration and a decent merge tool, though at work I use Araxis, and at home I use P4Merge which is free from Perforce.

    ~Scott

    ReplyDelete