Compare entire directories w git difftool + Beyond Compare

September 20, 2014

Nerd

HUGE shoutout to Jeff Knowlton for telling me about git difftool –dir-diff:
http://www.scootersoftware.com/support.php?zz=kb_vcs#gitwindows

This is how to set the path for Beyond Compare:

git config --global difftool.bc3.cmd "\"c:/Program Files/Beyond Compare 4/BCompare.exe\" \"$LOCAL\" \"$REMOTE\""

(use your path to your installation, of course)

Then, add an alias:

git config --global alias.diffdir = "difftool --dir-diff --tool=bc3 --no-prompt"

(Please note: the –tool & –no-prompt switches are important to ensure it runs with Beyond Compare, regardless of what difftool is set as default, either locally or globally).

Using this trick, I can do a full directory comparison of my ANY TWO COMMITS (snapshots) by simply typing:

   git diffdir     any-branch-name     any-other-branch-name

Of course, since a branch is just a pointer to a SHA-1 hash, you can also pass hashes:

   git diffdir 4bc7ba80edf6  7f566710c7

…or a mix of a branch name & a SHA-1 hash:

   git diffdir master 4bc7ba80edf6

COOLEST TRICK EVER – (so cool I had to share)
SO HELPFUL. Thanks, Jeff!!!

One Comment on “Compare entire directories w git difftool + Beyond Compare”

  1. Anonymous Says:

    When adding the alias, the equals sign (=) is not needed. simply use
    git config –global alias.diffdir “difftool –dir-diff –tool=bc3 –no-prompt”
    otherwise using git diffdir will result in an error.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: