A Fresh Cup is Mike Gunderloy's software development weblog, covering Ruby on Rails and whatever else I find interesting in the universe of software. I'm a full-time Rails developer and contributor, available for long- or short-term consulting, with solid experience in working as part of a distributed team. If you'd like to hire me, drop me a line. I'm also the author of Rails Rescue Handbook and Rails Freelancing Handbook.

Navigation
« Double Shot #306 | Main | Double Shot #305 »
Sunday
05Oct2008

External git merge on OS X

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.

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 | Unregistered CommenterGarry Bodsworth

[...] 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...

October 5, 2008 | Unregistered CommenterMike Gunderloy

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.

October 6, 2008 | Unregistered CommenterSam

Sam, Changes is at http://changesapp.com/ . It's nice for 2-way merge at the moment.

October 6, 2008 | Unregistered CommenterMike Gunderloy

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.

October 7, 2008 | Unregistered CommenterHo-Sheng Hsiao

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.

January 22, 2009 | Unregistered Commenterelliecomputing

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.

June 23, 2009 | Unregistered CommenterMartin

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.

October 15, 2009 | Unregistered Commenterj2

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>