我知道我可以链接到GitHub存储库上文件的特定行号(我相信我以前见过这个)…
我该怎么做呢?
我知道我可以链接到GitHub存储库上文件的特定行号(我相信我以前见过这个)…
我该怎么做呢?
当前回答
许多编辑器(但也参见下面的命令部分)支持链接到GitHub或Bitbucket(或其他)上的文件行号或范围。以下是一个简短的清单:
Atom
在GitHub上打开
Emacs
吉特链接
崇高的文本
GitLink
Vim
gitlink-vim
命令
Git -link - Git子命令,用于获取到Git对象的存储库浏览器链接 ghwd -打开与shell当前分支和工作目录匹配的GitHub URL
其他回答
See:
您可以使用永久链接在问题、pr等中包含代码片段。
引用:
创建到代码段的永久链接
链接到GitHub维基页面上的行号
我在寻找如何链接到GitHub维基页面上的特定位置时遇到了一些麻烦,最终找到了这个。这可能是常识,但我不知道,其他人可能会发现它有用。
浏览wiki文件时,您可以将鼠标放在特定的标题文本上,链接图标就会出现。单击此链接图标,您的浏览器导航URL将被更新(例如:https://github.com/user/repository/wiki/Test#title-1)。这将是到wiki文件中特定位置的链接。
气息。seib有一个复杂的答案,但我只是想指出,而不是按Y来获得永久链接,GitHub现在有一个非常简单的UI,帮助你实现它。
通过单击行号选择一行或通过按住Shift选择多行(与在文件资源管理器中选择多个文件夹的方式相同): 在选中的第一行的右上角,展开…然后单击“复制永久链接” 就是这样。一个包含选定行和提交散列的链接被复制到你的剪贴板: https://github.com/python/cpython/blob/c82b7f332aff606af6c9c163da75f1e86514125e/Doc/Makefile#L1-L4
有关如何链接到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
如果您想要获得Markdown代码片段的预览呈现,在复制另一个答案中提到的链接之后,从链接中删除?plain=1参数。
例如,下面将显示一个纯文本链接:
github.com/<organization>/<repository>/blob/<branch_name>/README.md?plain=1#L14
在移除?plain=1参数后,它将显示代码的预览:
github.com/<organization>/<repository>/blob/<branch_name>/README.md#L14
更多信息请参见GitHub文档:创建到代码片段的永久链接。