Using DiffMerge as external diff on SourceTree - rajivkanaujia/alphaworks GitHub Wiki

Background

Besides using command line to check Git (source control) changes, I like to use a visual too from time to time. Visual Studio Code has good support for such functionality.

I also use Sourcetree that gives me a better visuals for the repos I have cloned etc. However, when I try to use External Diff, the Sourcetree fails to load DiffMerge which I use for doing visual diffs. This article will help in configuring DiffMerge and Sourcetree to work together and enable DiffMerge as external diff tool.

Install DiffMerge

Download and install DiffMerge from https://sourcegear.com/diffmerge/ For Mac, the version I used at the time of writing this document was DiffMerge.4.2.1.1013.intel.stable.dmg Once you launch it you will find "Extras" folder. Copy the diffmerge.sh to a folder which is in your path. All my scripts are located at ~/Development/git/alphaworkspvt/scripts/ and they don't contain any secrets/keys in them (security is important).

Its a simple script to locate and execute DiffMerge command. Make changes as needed.

DIFFMERGE_PATH=/Applications/DiffMerge.app
DIFFMERGE_EXE=${DIFFMERGE_PATH}/Contents/MacOS/DiffMerge
exec ${DIFFMERGE_EXE} --nosplash "$@"

Install and configure Sourcetree

  1. Download and install Sourcetree from https://www.sourcetreeapp.com

  2. Configure Sourcetree so that you can see all your repositories (local or remote) that you work on.

    • Local

    • Remote

  1. Configure Diff in the Sourcetree properties. Although you will fine "DiffMerge" as one of the Visual Diff Tool or Merge Toll, it does not work unless you configure it as a Custom

    • Diff Command: /Users/rajiv/Development/git/alphaworkspvt/scripts/diffmerge.sh and Arguments: $LOCAL $REMOTE

    • Merge Command: /Users/rajiv/Development/git/alphaworkspvt/scripts/diffmerge.sh and Arguments: $LOCAL $REMOTE $BASE $MERGED

  2. Run an external Diff

    See the diff on the Sourcetree

    See the diff on the DiffMerge


Note: If you like the instructions here, please refer it on your posts/documentation. Contact me if there are corrections needed.