GitHub message commit link

Quickly link to a commit in a GitHub message. SHA: followed by the first 7 or so of the commit SHA for that project will be converted into a link. For example, I just dropped:

SHA: 49b5c3a6eb509

which became - SHA: 49b5c3a

More goodies in GitHub Flavored Markdown. You can also quickly reference other projects and branches.

GitHub link to source code with commit tree

When referencing source code in a GitHub project, it’s nice to be able to link to specific lines of a source file. GitHub makes this easy enough. From the main project page (github.com/jquery/jquery), you can browse to a specific file (github.com/jquery/jquery/blob/master/src/css.js) and then click on line numbers to highlight a line, which also sets the URL anchor (blob/master/srs/css.js#L171), and Shift+Click to highlight multiple lines (blob/master/srs/css.js#L171-185).

The only problem is that source files are subject to change, or even be removed, so there’s no guarantee that your link will always point to the correct place. By default, GitHub project pages link to the most current version of the source. A better practice is to link to a specific commit, where the content of source files are not subject to versioning.

To view a GitHub project at a certain commit, click on the tree link in the commit header, or just press t on your keyboard. You can then browse the project files, and link to sources of this commit, i.e. github.com/jquery/jquery/blob/27291ff06ddb655f90a8d1eada71f7ac61499b12/src/css.js#L171-185. Note that the only difference in the URL is changing the branch name master with the commit SHA.

+1 tip from Paul Irish:

plus you only need 4 characters of the SHA in the URL.. it figures it out. i usually truncate to 7ish characters.

Nice: github.com/jquery/jquery/blob/27291ff/src/css.js#L171-185

Gollum wiki downers

I’ve been fiddling with a Gollum wiki and found a couple disappointments running locally.

  • Changes must be committed in the git repo before they are seen in the wiki.
  • Gollum only runs from master branch. Issue 94. Coupled with the previous issue, this prevents any way to preview changes. If you wish to view changes, you must commit to the master branch.
  • If the Home page is missing, no table of contents will be automatically generated (as they are on GitHub). Issue 74
  • Sidebars are not added to pages (as they are on GitHub). Issue 97

These issues are all bummers considering how slick Jekyll is.