Hacker News new | ask | show | jobs
by codingkev 1585 days ago
You can link directly to a line by appending #<line_number>

https://github.com/torvalds/linux/blob/f4bc5bbb5fef3cf421ba3...

4 comments

Another fun github hack: if you browse the repo for a particular file, the URL will be something like

    github.com/user/repo/blob/master/foo/bar/baz.py
But this file can change, meaning this url might not have the same content a week or month down the road. This is particularly troublesome when you have lines selected. To fix this, press `y` and your url will get expanded to include the current commit hash:

    github.com/user/repo/blob/e4ecae.../foo/bar/baz.py
Now your URL is safe to share.
You can also change "github.com" to "github1s.com" or "github.dev" if you want to view it in VSCode in browser.

i.e.

https://github.dev/torvalds/linux/blob/f4bc5bbb5fef3cf421ba3...

https://github1s.com/torvalds/linux/blob/f4bc5bbb5fef3cf421b...

Or just press '.' if you're logged in
Or just click on the line number to change the URL to that line.
And shift-click on a second line to select a block.
I tried that but everything after the # got stripped when I submitted the link.