我知道我可以链接到GitHub存储库上文件的特定行号(我相信我以前见过这个)…
我该怎么做呢?
我知道我可以链接到GitHub存储库上文件的特定行号(我相信我以前见过这个)…
我该怎么做呢?
当前回答
单击行号,然后从地址栏复制并粘贴链接。若要选择一个范围,请单击该数字,然后单击后面的数字。
或者,链接是一种相对简单的格式,只需将#L<number>附加到特定行号的末尾,使用到文件的链接。这是git仓库README的第三行链接:
https://github.com/git/git/blob/master/README#L3
其他回答
链接到GitHub维基页面上的行号
我在寻找如何链接到GitHub维基页面上的特定位置时遇到了一些麻烦,最终找到了这个。这可能是常识,但我不知道,其他人可能会发现它有用。
浏览wiki文件时,您可以将鼠标放在特定的标题文本上,链接图标就会出现。单击此链接图标,您的浏览器导航URL将被更新(例如:https://github.com/user/repository/wiki/Test#title-1)。这将是到wiki文件中特定位置的链接。
许多编辑器(但也参见下面的命令部分)支持链接到GitHub或Bitbucket(或其他)上的文件行号或范围。以下是一个简短的清单:
Atom
在GitHub上打开
Emacs
吉特链接
崇高的文本
GitLink
Vim
gitlink-vim
命令
Git -link - Git子命令,用于获取到Git对象的存储库浏览器链接 ghwd -打开与shell当前分支和工作目录匹配的GitHub URL
See:
您可以使用永久链接在问题、pr等中包含代码片段。
引用:
创建到代码段的永久链接
有关如何链接到README。md文件的GitHub存储库到特定行数的代码
有三种情况:
We can link to (custom commit) But Link will always link to an old file version, which will not contain new updates in the master branch for example. Example: https://github.com/username/projectname/blob/b8d94367354011a0470f1b73c8f135f095e28dd4/file.txt#L10 We can link to (custom branch) like (master-branch). But the link will always link to the latest file version which will contain new updates. Due to new updates, the link may point to an invalid business line number. Example: https://github.com/username/projectname/blob/master/file.txt#L10 GitHub can not make an auto-link to any file either to (custom commit) nor (master-branch). Because of following business issues: line business meaning, to link to it in the new file length of target highlighted code which can be changed
用于拉取请求中的一行。
https://github.com/foo/bar/pull/90/files#diff-ce6bf647d5a531e54ef0502c7fe799deR27
https://github.com/foo/bar/pull/
90 <- PR number
/files#diff-
ce6bf647d5a531e54ef0502c7fe799de <- MD5 has of file name from repo root
R <- Which side of the diff to reference (merge-base or head). Can be L or R.
27 <- Line number
只要L和R是正确的,就会得到一条直线。我不确定是否有方法访问L或r,即如果PR增加了一行,你必须使用r。如果它删除了一行,你必须使用L。
从:生成行指针URL到Github拉请求