Leveraging github for presentation of changes

Github has a polished and functional interface for (re)viewing changes to a file or more generally change sets to a project.
Most can skip the following setup section and jump to the summary of options for viewing existing repositories.

Repository setup

I'll describe how I setup local forks for a project by explaining how I work with the github coreutils mirror. I forked that mirror to my a/c on github and then in my standard coreutils local repo I did:
$ git remote add github git@github.com:pixelb/coreutils.git
$ git fetch github
That worked immediately since there were no new commits. I have repos and branches set like this in .git/config, which allows me to update my github-master branch periodically.
[remote "github"]
    url = git@github.com:pixelb/coreutils.git
    fetch = +refs/heads/*:refs/remotes/github/*
[branch "selinux-restorecon"]
    remote = github
    merge = refs/heads/selinux-restorecon
[branch "github-master"]
    remote = github
    merge = refs/heads/master
Now I can (force) push my branches to my github fork like:
$ git push github +selinux-restorecon

I also removed all but the master branch and my own branches from my github fork, to make it obvious which branches were the ones I wanted to make available.

Presentation of changes

With commits in github we can leverage some functional and interface advantages for working collaboratively on change sets.
The functional part of each URL is highlighted below.

Branch specific commits

github has a great viewer for topic branches, which shows each commit specific to the branch,
supporting comments/reviews on the changes. For e.g.:
https://github.com/pixelb/coreutils/compare/selinux-restorecon

Branch specific visual diff

Also very useful is to see the combined changes on a per file basis, using:
https://github.com/pixelb/coreutils/compare/selinux-restorecon#files_bucket

One can even reference a particular diff within the set of changes directly like:
https://github.com/pixelb/coreutils/compare/selinux-restorecon#diff-8

Visual file (change) display options

Since Sep 2014 the github diff viewer supports side by side mode, which it calls split diffs, and improved changed word highlighting which you can see at the above link. You can explitly choose "split" or "unified" view, with or without whitespace only changes. For example, remove the "w=1" in the following to see the whitespace only diff.
https://github.com/pixelb/ps_mem/commit/f0f5353d?diff=split&w=1

While not related to diffs, it's also worth mentioning github's support for linking and highlighting a range of lines. As well as the line range, please note the use of a specific hash to ensure the permanence of the link.
https://github.com/pixelb/crudini/blob/50b9300/crudini#L58-L94

Patch set extraction

If you want to reference a raw patch set for piping to git am without having to worry about setting up git remotes etc., just tack a ".patch" on the end of the changeset link like:
https://github.com/pixelb/coreutils/compare/selinux-restorecon.patch

You can also extract just the diff, and do this against specific repos, branches and tags. For example to extract the diff for the latest current release, of the coreutils LI18NUX modifications, one can compute the diff between the coreutils mirror and the i18n branch in my fork like:
https://github.com/coreutils/coreutils/compare/v8.24...pixelb:i18n.diff

© Nov 5 2015