Skip navigation

I just installed TextWrangler (the free version of BBEdit), and am SO GLAD to kiss Aquamacs goodbye.

TextWrangler is so great, it even has a built-in diff comparison and merge tool. The REALLY cool thing is that you can use it as an external diff program with Git!

Here’s how (thanks to Jotlab’s post on How to use FileMerge with Git as a Diff Tool on OSX for giving me the idea):

~/git-twdiff.sh:

#!/bin/sh
/usr/bin/twdiff --wait "$2" "$5"

Then, just tell Git to use your script as the external diff editor:

git config --global diff.external ~/git-twdiff.sh

6 Comments

  1. I found that I needed to add cat to the end of git-twdiff.sh, like so:
    “/usr/bin/twdiff –resume –wait “$2″ “$5″ | cat”

  2. There’s lots prettier way of doing this:

    git config –global –add “difftool.twdiff.cmd” “twdiff –wait \”\$LOCAL\” \”\$REMOTE\”"
    git config –global diff.tool twdiff

    or use diff.external if you prefer.

  3. Thanks for the tip, but I couldn’t get it to work with git diff’s –ext-diff option. I created the file git-twdiff.sh, made it executable, and ran it via:

    git diff –ext-diff git-twdiff.sh

    but no go – it returns with no output. Any ideas? Thanks!

  4. @Matthew forget about creating a file for that, use my previous tip among comments. Cheers!

  5. Thanks, Ali. I was trying to avoid a global change, but hey – it’s Git. I can simply edit the file if I change my mind :-)

  6. Thanks for the script! When I was about to use it, I peaked inside my global .gitconfig file before doing so and apparently my SourceTree install which had TextWrangler set as its diff tool, had already made the changes on my behalf :)


Leave a Reply