I want to click a hotkey and copy the URL for the repo version of the particular line of code I am on to my clipboard (so I can share it with people).
Asked
Active
Viewed 8,797 times
19
-
do you mean the commit id? – rioV8 Jul 22 '20 at 23:53
-
I mean a link to that specific line of code, on the remote version of the branch I am working on - e.g. if I am working on the master branch of the webpack repo, and I am on this line in this file, it gives me this link to the line https://github.com/webpack/webpack/blob/master/package.json#L2 – Andrew Jul 22 '20 at 23:59
-
I know how to do it in Intellij so I assume this is also a feature of VS – Andrew Jul 22 '20 at 23:59
1 Answers
26
The extension Gitlens by Eric Amodio gives the Copy Remote URL
option in the context menu.
The command is: gitlens.copyRemoteFileUrlToClipboard

rioV8
- 24,506
- 3
- 32
- 49
-
2I don't see it in the command palette after installing - do I need to configure anything else? – Andrew Jul 23 '20 at 01:06
-
2@Andrew If I search for `url` in command palette I get 3 hits and 1 of them is from GitLens. Maybe restart VSC. – rioV8 Jul 23 '20 at 07:43
-
Restart, yes, and make sure you open your file from the repo. Otherwise gitLens won't give you list of commands. You can also add a key binding as suggested here: https://stackoverflow.com/questions/74284047/how-to-copy-a-url-of-code-line-in-vscode/74284072#74284072 – exomen Nov 02 '22 at 19:45
-
Thanks, exactly what I was looking for. To have this command works, you also have to configure the remote provider, following this instruction https://github.com/gitkraken/vscode-gitlens#remote-provider-integration-settings- – Sisi Liao Feb 01 '23 at 19:38