如何引用 github 中的特定行或行范围?

2024-03-09

如果您想添加对特定行或一系列行的引用,最好获得一个可以执行此操作的 URL。


请注意,问题在于#Lxx-Lyy是(从这个帖子 http://dropshado.ws/post/8347781227/github-link-to-source-code-with-commit-tree):

源文件可能会发生变化,甚至被删除,所以有不保证您的链接始终指向正确的位置.
默认情况下,GitHub 项目页面链接到最新版本的源代码。更好的做法是链接到特定提交,其中源文件的内容不受版本控制。

To view a GitHub project at a certain commit, click on the tree link in the commit header, or just press t on your keyboard. You can then browse the project files, and link to sources of this commit, i.e.

http://github.com/jquery/jquery/blob/27291ff06ddb655f90a8d1eada71f7ac61499b12/src/css.js#L171-L185 http://github.com/jquery/jquery/blob/27291ff06ddb655f90a8d1eada71f7ac61499b12/src/css.js#L171-L185.

请注意,URL 中的唯一区别是使用提交 SHA 更改分支名称 master。

Paul Irish 的 +1 提示:

另外,您只需要 URL 中的 SHA 的 4 个字符……它弄清楚了。
我通常会截断到 7 个字符。

Nice: http://github.com/jquery/jquery/blob/27291ff/src/css.js#L171-185 http://github.com/jquery/jquery/blob/27291ff/src/css.js#L171-185


If you have a GitHub page which does not reference a sha1, type y:
that will reload that same page with the current SHA1.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何引用 github 中的特定行或行范围? 的相关文章

随机推荐