Finding a good (free) diff tool is hard for OS X. Here, we’ll setup Meld (a popular diff tool on linux) to run with OS X and git.
First, install a decent Mac build of Meld, there’s a few options but here’s one I really like:
Once this is installed, you need to make bash script so Meld is command-line executable and can be invoke through git. Name this file ‘meld’ and place it in a sourced directory that you can run commands from globally. I like to set up a ~/bin directory where I can put scripts like this and magerun so I can run them from anywhere, but you may have a better place for it on your system. You can source a directory by adding the following to the bottom of your ~/.zshrc or ~/.bash_profile:
Create a ‘meld’ file in this directory and use the following contents:
$ cat ~/bin/meld
#!/usr/bin/python import sys import os import subprocess if len(sys.argv) > 1: left = os.path.abspath(sys.argv); else: left = "" if len(sys.argv) > 2: right = os.path.abspath(sys.argv); else: right = "" if len(sys.argv) > 3: merged = os.path.abspath(sys.argv); else: merged = "" MELDPATH = "/Applications/Meld.app" arguments = " -n " + MELDPATH + " --args " + left + " " + merged + " " + right p = subprocess.call(['open', '-W', '-a', MELDPATH, '--args', left, merged, right])
And finally, add the following to your ~/.gitconfig
[mergetool "meld"] cmd = meld \"$LOCAL\" \"$REMOTE\" \"$MERGED\" trustexitcode = true
And give it a shot!