Review Git PRs with Beyond Compare

Stefan
2 min readJun 9, 2017

Whether you are using GitHub Desktop or Atlassian’s SourceTree (or their respective web views), it is always nice to use an external diff editor.

While all diff editors out there are pretty good, my diff editor of choice is Beyond Compare.

Let’s get started. At a terminal prompt, enter these commands:

git config --global diff.tool bc
git config --global difftool.bc.trustExitCode true

On Windows, you will need to enter this additional command:

git config --global difftool.bc.path "c:/Program Files/Beyond Compare 4/bcomp.exe"

When you’re ready to commit your changes to your repo, use this command to compare them:

git difftool

That’s nice and all, but if you’re reviewing someone else’s code, then you’re not really interested in differences between two commits, because your colleague’s branch might contain many of them. You will want to compare all of the work done since it diverged from master.

bcreview is a useful command to do code reviews (shamelessly “borrowed” from ksreview by Doug Russell and Kevin Ballard).

To install bcreview simply enter this command:

git config --global alias.bcreview '!f() { local SHA=${1:-HEAD}; local BRANCH=${2:-master}; if [ $SHA == $BRANCH ]; then SHA=HEAD; fi; git difftool -y -t bc $BRANCH...$SHA; }; f'

To use bcreview while you’re on a branch, assuming your mainline branch is master, just enter this command:

git bcreview

If you’re on a different branch or your mainline isn’t master, you can be more specific:

git bcreview feature-branch-name mainline-branch-name

To the awesome people at Scooter Software: please allow me to comment on code from within Beyond Compare (without switching to the pull request on the web), because that would then make your product shine and leave the competition in the dust.

--

--

Stefan

Delphi/Rust/Go developer. Ethereum consultant. Embarcadero MVP. Ex-Adobe, Macromedia. Helped build 1Password.