Sunday
05Oct2008
External git merge on OS X
Sunday, October 5, 2008 at 4:58AM
The default merging behavior of git is pretty good - until it blows chunks and litters your merged file with dozens of >>>> markers. I had this happen to me again this weekend, and was finally motivated to do something about it.
To change the default merging behavior in git, you run
git config --global merge.tool toolname
To see the list of available tools, type
git mergetool
Most of the tools that git understands are unix-y. There is one OS X tool on the list: opendiff, which launches the FileMerge tool. But honestly, I've never been that impressed with FileMerge's merge algorithm.
Fortunately, xxdiff is a pretty good tool, and it's available as a Darwin port. So, assuming you already have your OS X box set up to install ports, you can have this as your default git merge user interface by running:
sudo port install xxdiff
git config --global merge.tool xxdiff
Now files needing a merge will open in the xxdiff user interface - which is an ugly XWindows thing, but it's powerful. I'd love to see git hook up to something like Araxis Merge or Changes (when their 2.0 version with 3-way merge comes out), but I'm not nearly motivated enough to hack around in the git source yet.
To change the default merging behavior in git, you run
git config --global merge.tool toolname
To see the list of available tools, type
git mergetool
Most of the tools that git understands are unix-y. There is one OS X tool on the list: opendiff, which launches the FileMerge tool. But honestly, I've never been that impressed with FileMerge's merge algorithm.
Fortunately, xxdiff is a pretty good tool, and it's available as a Darwin port. So, assuming you already have your OS X box set up to install ports, you can have this as your default git merge user interface by running:
sudo port install xxdiff
git config --global merge.tool xxdiff
Now files needing a merge will open in the xxdiff user interface - which is an ugly XWindows thing, but it's powerful. I'd love to see git hook up to something like Araxis Merge or Changes (when their 2.0 version with 3-way merge comes out), but I'm not nearly motivated enough to hack around in the git source yet.

Reader Comments (9)
I blogged about some of this here : http://blog.programmerslog.com/?p=167 which links to the following two articles:
P4Merge or Diffmerge - http://blog.logicalrand.com/2008/9/9/use-p4merge-or-diffmerge-with-git-mergetool-on-os-x
KDiff3 - http://notch8.com/articles/2008/06/06/kdiff3-git-win
Garry
[...] October 5, 2008 External git merge on OS X Posted by Daniel under code, tech External git merge on OS X: [...]
Argh ... yes, that's two dashes before global, but unfortunately the blog typography is turning it into a hyphen. There must be some way to disable that...
Does anyone have a link to the Changes diff tool Mike refers to? Nearly impossible to google for the likes of 'changes diff utility'. Thanks.
Sam, Changes is at http://changesapp.com/ . It's nice for 2-way merge at the moment.
The GTK app, meld is the best one so far, since it gives you a three-panel instead of a two-panel merge. Its disadvantage for OSX users is that it is not a Cocoa-native app. I have heard that the merge tool that is being built into gitx will lhave a similar functionality.
there is also an integration for ECMerge in git, and ECMerge is available in OS X, so it should probably work out of the box.
xxdiff has 3-way merge, and a merged panel as well.
Check out the documents on my website about the myriad not-so-obvious features of xxdiff.
I really should port it to Qt4 at some point... other projects are getting in the way.
I love xxdiff since I'm developing on FreeBSD over SSH from an OSX box. It has a crazy amount of useful features but many are hidden. The clipboard is one that comes to mind.
Something else you might want to check out is DiffMerge - free as in beer but not speech. One nice additional feature is editing in place.
Diffmerge isn't an option for my FreeBSD development due to the freespeech problem (and not running on FreeBSD) and sshfs and git being too slow to run git effectively.