j-dlsq
Last Updated: April 07, 2017
·
4.21K
· mislav
8f93a872e399bc1353cc8d4e791d5401

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:

github.com/sstephenson/rbenv#readme

Say Thanks
Respond

1 Response
Add your response

5292
8e5925c73b767f566b9ab39225df9e5b

Never heard of this shortcut. Thanks!

over 1 year ago ·
Filed Under