Read more

Getting permanent links to files on Github or Gitlab

Henning Koch
March 19, 2015Software engineer at makandra GmbH

Please don't simply copy line number links from Github. The URL usually contains a branch name like master which will change over time:

https://github.com/makandra/upjs/blob/master/lib/assets/javascripts/up/link.js.coffee#L76
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

If someone now posts an insertion or deletion to that file into master your link points to the wrong line!

A better way is to press the Y key after clicking on a line number. This will transform the URL to another URL that points to the particular commit:

https://github.com/makandra/upjs/blob/b3b1491dfa1e3e83265ef228631382868909c617/lib/assets/javascripts/up/link.js.coffee#L76

You can also use tags for a more human readable format, if they are available:

# Link to GitHub:
https://github.com/makandra/upjs/blob/v0.13.0/lib/assets/javascripts/up/link.js.coffee#L76

# Link to the raw file:
https://raw.githubusercontent.com/makandra/upjs/v0.13.0/lib/assets/javascripts/up/link.js.coffee
Posted by Henning Koch to makandra dev (2015-03-19 12:07)