Skip to content

Instantly share code, notes, and snippets.

@kylefox
Created January 11, 2013 18:15
Show Gist options
  • Select an option

  • Save kylefox/4512777 to your computer and use it in GitHub Desktop.

Select an option

Save kylefox/4512777 to your computer and use it in GitHub Desktop.
If you want to use Xcode's FileMerge as your git mergetool, this is how you set it up.
# Tell system when Xcode utilities live:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
# Set "opendiff" as the default mergetool globally:
git config --global merge.tool opendiff
@intel352

intel352 commented Oct 5, 2015

Copy link
Copy Markdown

@kylefox, I actually have a binary existing at /usr/bin/opendiff already, which is not a symlink, and last modified date shows it to be physically older than the version at /Applications/Xcode.app/Contents/Developer/usr/bin/opendiff. So using the git line that you have, seems that would find the version that is specified at /usr/bin/opendiff, rather than the xcode version, right? Or does the app itself then refer back to Xcode for the proper location to open?

@alanwill

Copy link
Copy Markdown

@intel352 per the opendiff man page:

opendiff is a command line utility that provides a convenient way to launch the FileMerge application from Terminal to graphically compare files or directories. If FileMerge is already running, opendiff will connect to that running instance for the new comparison. opendiff exits immediately after the comparison request has been sent to FileMerge.

@connorbode

Copy link
Copy Markdown

thx

@k7n4n5t3w4rt

Copy link
Copy Markdown

phew. thanks. vimdiff was killing me.

@KokoDoko

Copy link
Copy Markdown

Am I correct that I still have to open the tool manually by typing "git mergetool" after a merge conflict? Or should this happen automatically?

@tooluser

tooluser commented May 6, 2016

Copy link
Copy Markdown

You are correct KokoDoko.

@ndstephens

Copy link
Copy Markdown

thank you. exactly what i was looking for

ghost commented Aug 22, 2018

Copy link
Copy Markdown

Fantastic, thank you!

@domoench

Copy link
Copy Markdown

πŸ‘

@shameen

shameen commented Feb 17, 2021

Copy link
Copy Markdown

I also ran this, so after saving changes and exiting, git wouldn't ask "Was the merge successful? [y/n]?"

git config --global mergetool.opendiff.trustExitCode true

(Credit: https://stackoverflow.com/q/10656719/4810109)

@granchenkooleg

Copy link
Copy Markdown

πŸ‘

@YeeJiaWei

Copy link
Copy Markdown

thank you πŸ‘πŸ»

@pryder-fleetaero

Copy link
Copy Markdown

πŸ‘ Still useful 10 years on

@jms1voalte

Copy link
Copy Markdown

😎 Thanks for this.

@nest-don

nest-don commented Oct 4, 2022

Copy link
Copy Markdown

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment