Skip to content

Instantly share code, notes, and snippets.

@kylefox
Created January 11, 2013 18:15
Show Gist options
  • Save kylefox/4512777 to your computer and use it in GitHub Desktop.
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
@soffes
Copy link

soffes commented Aug 19, 2015

πŸ‘

@intel352
Copy link

intel352 commented Oct 5, 2015

@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

@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

thx

@k7n4n5t3w4rt
Copy link

phew. thanks. vimdiff was killing me.

@KokoDoko
Copy link

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
Copy link

tooluser commented May 6, 2016

You are correct KokoDoko.

@ndstephens
Copy link

thank you. exactly what i was looking for

Copy link

ghost commented Aug 22, 2018

Fantastic, thank you!

@domoench
Copy link

πŸ‘

@shameen
Copy link

shameen commented Feb 17, 2021

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

πŸ‘

@YeeJiaWei
Copy link

thank you πŸ‘πŸ»

@pryder-fleetaero
Copy link

πŸ‘ Still useful 10 years on

@jms1voalte
Copy link

😎 Thanks for this.

@nest-don
Copy link

nest-don commented Oct 4, 2022

thanks

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