Github’s Compare View

GitHub recently hit one million users, and in celebration of this fact, I thought that I’d post about some of GitHub’s hidden but useful features. The first one I want to show you is compare view:

Compare view is GitHub’s online git diff. It’s a fantastic way of doing code reviews, especially when multiple commits are involved.

On the top left, you can see the two branches that are being compared. In this case, I am comparing my develop branch to t1660c. In the middle you see all the commits that are part of this compare view. I’ve only got one here, but you could do something ridiculous like comparing Processing.js v1.2.1 to v1.2.3. And on the bottom of the page we have all of the diffs for each file modified in the compare view. If you have more than 50 commits, then the diff is put on a different tab.

Accessing a compare view can be done in two different ways:

  1. You can build the compare view URL manually with the following format:[USER:]GIT-REF[USER:]GIT-REF. USER is your GitHub username, REPO is your GitHub repository, and GIT-REF can be a tag, branch, or commit SHA1. It’s also possible to do cross-repository compares by prepending another GitHub username to the git ref, with a colon dividing the username and git ref.
  2. Use the branch list page by clicking on the Source tab, then the Branch List subtab. Besides each branch is a Compare button.

Of the two ways to do a compare view, I prefer creating it from the URL because it’s faster. If you want to read more about GitHub’s Compare View, you can read the official blog posts:


This entry was posted in Open Source. Bookmark the permalink.