Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I sometimes have to make git merges on the console. Up to now, for resolving conflicts, I was using Xcode 3's FileMerge (you can open it on the console using the 'opendiff' command). If conflicts show, I use 'git mergetool' which automatically invokes opendiff for each of the conflicting files.

However, Xcode 4 features a much nicer mergetool component for resolving conflicts. I believe this component is part of the Xcode 4 executable, rather than standalone. It allows you to preview the merged file, and directly edit merged code on a case-by-case basis, which makes merging complex conflicts incredibly fast and satisfactory.

Is there any way to use the Xcode 4 mergetool when invoking 'git mergetool' from the Terminal?

I cannot find an executable for this tool inside the Xcode 4 bundle. Any hack that achieves this would be welcome.

share|improve this question
    
In case anybody else is interested in this feature: it seems there is no official way of doing it. I submitted a feature request to Apple through bugreport. Here's the radar. I guess it's quite hopeless, but you never know. For anybody else interested, I suggest showing interest by submitting a similar bug report to Apple. –  Ricardo Sánchez-Sáez Apr 8 '13 at 19:33

3 Answers 3

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.

share|improve this answer
    
Thanks for trying to help, but Filemerge/opendiff is not what I am trying to use. Also, I tried DiffMerge (and DeltaWalker for what it's worth) and I don't like its UI very much. Kaleidoscope is waaay nicer, but it doesn't feature merging/editing, just difference showing. –  Ricardo Sánchez-Sáez Aug 18 '11 at 16:49
    
I'm pretty sure Xcode 4 is just wrapping FileMerge. I discovered the same disappointment about Kaleidoscope. –  Dan Ray Aug 18 '11 at 17:03
    
I would say Xcode 4 is not wrapping FileMerge. On FileMerge you cannot edit the merged file, you just select which side of the merge you want to use for each conflict. On Xcode 4 pull-conflict resolver you can edit the conflicting lines and do a pull with the file the exact way you want it to be. Besides, the UI is completely different from Filemerge. –  Ricardo Sánchez-Sáez Aug 18 '11 at 17:05
1  
Kaleidoscope 2 beta was recently released, and it allows inline editing of merged files. Check it out, it's quite good. The only thing it's missing is a different color for conflicts (it uses the same color as code substitution for those). –  Ricardo Sánchez-Sáez Dec 6 '12 at 2:22
    
After some months using Kaleidoscope and despite it being generally good, I have to say that it's still kind of buggy and/or confusing, specially when compared to Xcode 4.x conflict-resolving component. Still hoping for Apple to do the unexpected and implement it as a standalone tool invokable from, say, Tower. ;-) –  Ricardo Sánchez-Sáez Jun 30 '13 at 16:13

You can edit in the (very basic) text editor within FileMerge by opening the editor pane -- which is closed by default. To open the editor in FileMerge, drag the dot below the center diff column up to open the editor pane.

share|improve this answer

This ended up working for me

[merge]
  tool = opendiff

[mergetool]
  keepBackup = false

[mergetool "opendiff"]
  cmd = "opendiff \"$LOCAL\" \"$REMOTE\" -merge \"$MERGED\""
share|improve this answer
2  
Opendiff is what Xcode 3.x used for merges. My question was about Xcode 4.x merge component, which is a completely different tool (it allows inline editing of the resulting file, unlike opendiff/filemerge). Thanks anyway. –  Ricardo Sánchez-Sáez Dec 6 '12 at 2:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.