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 setupI'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 firstname.lastname@example.org:pixelb/coreutils.git $ git fetch githubThat 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 = email@example.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/masterNow 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 changesWith 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 commitsgithub has a great viewer for topic branches, which shows each commit specific to the branch,
supporting comments/reviews on the changes. For e.g.:
Branch specific visual diffAlso very useful is to see the combined changes on a per file basis, using:
One can even reference a particular diff within the set of changes directly like:
Visual file (change) display optionsSince 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.
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.
Patch set extractionIf 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:
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: