How to use Xcode 4 mergetool in a standalone fashion?

opendiff takes two filename arguments, and an --ancestor parameter with a third filename, to produce a three-way diff, and a --merge parameter to say the output file to use for the conflict resolution.

So go:

[mergetool "opendiff"]
    cmd = "opendiff \"$LOCAL\"  \"$REMOTE\" \"$(if test -f \"$BASE\"; then echo \"--ancestor $BASE\"; else echo \"--ancestor $LOCAL\"; fi)\" --merge=\"$MERGED\" "
[merge]
    tool = opendiff

That should make git use opendiff as its merge tool, when there are merge conflicts.

That said, I VERY much prefer DiffMerge from SourceGear, which is a free diff and three-way-merge tool that does much better, word-oriented, conflict resolution. And in DiffMerge's documentation there's what to tell git to make it the default diffing and merging tool.