如何在 GitHub 上的问题评论中引用提交?
我找到了很多关于如何在 git 评论中引用 GitHub 问题的答案(使用 #xxx 符号)。 我想在评论中引用提交,生成提交详细信息页面的链接?
I find a lot of answers on how to reference a GitHub issue in a git comment (using the #xxx notation).
I'd like to reference a commit in my comment, generating a link to the commit details page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
要引用提交,只需编写其 SHA 哈希值,它就会自动转换为链接。
或者使用其前缀
另请参阅:
在 GitHub 上写作。
To reference a commit, simply write its SHA-hash, and it'll automatically get turned into a link.
Or use its prefix
See also:
Writing on GitHub.
上面的答案缺少一个可能不明显的例子(对我来说不是)。
Url 可以分解为多个部分
Hash 可以在这里找到(您可以单击它并从浏览器获取 url)。
希望这可以节省您一些时间。
Answer above is missing an example which might not be obvious (it wasn't to me).
Url could be broken down into parts
Hash can be found here (you can click it and will get the url from browser).
Hope this saves you some time.
如果您尝试引用问题所在的另一个存储库中的提交,则可以使用
reponame@
为提交短哈希添加前缀。假设您的提交位于名为
dev
的存储库中,GitLab 问题位于名为test
的存储库中。如果有意义的话,您可以对该问题发表评论,并通过dev@e9c11f0a
引用提交(其中 e9c11f0a 是您要链接到的提交的 sha 哈希值的前 8 个字母)。If you are trying to reference a commit in another repo than the issue is in, you can prefix the commit short hash with
reponame@
.Suppose your commit is in the repo named
dev
, and the GitLab issue is in the repo namedtest
. You can leave a comment on the issue and reference the commit bydev@e9c11f0a
(where e9c11f0a is the first 8 letters of the sha hash of the commit you want to link to) if that makes sense.只需将提交引用链接粘贴到评论中,github 就会自动提及评论中的提交。
Just paste the commit referencing link in the comment github automatically mentions the commit on the comment.
我认为没有人回答这个问题,也许十年前这是不可能的。
但是现在,根据 github 文档 不需要哈希值。可以这样完成:
个人帐户
示例:对于 https://github.com/aUser/user-repo/issues/23
使用:
aUser/user-repo#26
组织
示例:对于 https://github.com/an-org/theirproject/issues/1000
使用:
an-org/theirproject#1000
I don't think anyone answered the question as asked, perhaps it wasn't possible a decade ago.
However now, as per the github documentation a hash is not required. It can be done thusly:
Individual account
example: for the issue at https://github.com/aUser/user-repo/issues/23
use:
aUser/user-repo#26
Organization
example: for the issue at https://github.com/an-org/theirproject/issues/1000
use:
an-org/theirproject#1000