Reputation: 91881
If I want to reference specific line numbers on GitHub, I can do so by finding the file on GitHub, and selecting the line numbers on the left.
I get a URL such as this:
https://github.com/apple/swift/blob/master/stdlib/public/core/Optional.swift#L190-L199
The problem is that this reference has /master/
in it, meaning that if the file ever changes, the lines it will highlight are probably not the ones that I intended to highlight. How can I get a static version of this file so that I can reference this exact code I'm referring to?
Upvotes: 0
Views: 64
Reputation: 91881
Scroll to the top of the page, and you'll see a SHA of the latest commit.
Replace master
in the URL with the SHA; 6d1ae2a
in this case:
https://github.com/apple/swift/blob/6d1ae2a/stdlib/public/core/Optional.swift#L190-L199
Scroll to the top of the page, and you'll see a SHA of the latest commit. Click the SHA (6d1ae2a in this case).
Click "Browse files" on the top right.
Find the file again. Now instead of master
, you'll see the SHA in the tree:
Highlight the lines as you did before and copy the URL:
Upvotes: 1