Your GitHub URLs should be timeless
Most folks publish GitHub URLs to view some code like so:
github.com/sstephenson/rbenv/blob/master/libexec/rbenv-help#L89-97
Even if it doesn't highlight any line numbers in particular, it's still a bad idea to have "master" as revision in the URL. In the future, the version of this file in the master branch will probably be different, or even non-existing (file got renamed/removed).
Whenever you link to some code, ensure the revision is a particular tag or SHA, because those won't change. Here's the proper link for the above example:
github.com/sstephenson/rbenv/blob/dba1014/libexec/rbenv-help#L89-97
To get that in the browser on GitHub.com, press <kbd>y</kbd> to expand the URL to its permalink form. (Thanks, Andy!)
From Vim and Fugitive.vim, it's easy to copy the URL for the current file/visual selection to the clipboard:
:Gbrowse! -
Bonus advice: whenever you link to projects on GitHub, append #readme
to the URL. Most visitors are interested primarily in the Readme and this will save them from always having to scroll down past the file listing:
Written by Mislav Marohnić
Related protips
1 Response
Never heard of this shortcut. Thanks!