如何在 GitHub 上的问题评论中引用提交?

发布于 2024-12-27 13:08:00 字数 80 浏览 1 评论 0原文

我找到了很多关于如何在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

撩起发的微风 2025-01-03 13:08:00

要引用提交,只需编写其 SHA 哈希值,它就会自动转换为链接。

the commit 3e5c1e60269ae0329094de131227285d4682b665 solved the issue...

或者使用其前缀

the commit 3e5c1e6 solved the issue...

另请参阅:

To reference a commit, simply write its SHA-hash, and it'll automatically get turned into a link.

the commit 3e5c1e60269ae0329094de131227285d4682b665 solved the issue...

Or use its prefix

the commit 3e5c1e6 solved the issue...

See also:

素年丶 2025-01-03 13:08:00

上面的答案缺少一个可能不明显的例子(对我来说不是)。

Url 可以分解为多个部分

https://github.com/liufa/Tuplinator/commit/f36e3c5b3aba23a6c9cf7c01e7485028a23c3811
                  \_____/\________/       \_______________________________________/
                   |        |                              |
            Account name    |                      Hash of revision
                        Project name              

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

https://github.com/liufa/Tuplinator/commit/f36e3c5b3aba23a6c9cf7c01e7485028a23c3811
                  \_____/\________/       \_______________________________________/
                   |        |                              |
            Account name    |                      Hash of revision
                        Project name              

Hash can be found here (you can click it and will get the url from browser).

enter image description here

Hope this saves you some time.

半步萧音过轻尘 2025-01-03 13:08:00

如果您尝试引用问题所在的另一个存储库中的提交,则可以使用 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 named test. You can leave a comment on the issue and reference the commit by dev@e9c11f0a (where e9c11f0a is the first 8 letters of the sha hash of the commit you want to link to) if that makes sense.

明天过后 2025-01-03 13:08:00

只需将提交引用链接粘贴到评论中,github 就会自动提及评论中的提交。

Just paste the commit referencing link in the comment github automatically mentions the commit on the comment.

老旧海报 2025-01-03 13:08:00

我认为没有人回答这个问题,也许十年前这是不可能的。

但是现在,根据 github 文档 不需要哈希值。可以这样完成:

个人帐户

用户名/存储库# 和问题或拉取请求编号

示例:对于 https://github.com/aUser/user-repo/issues/23

使用:aUser/user-repo#26

组织

Organization_name/Repository# 和问题或拉取请求编号

示例:对于 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

Username/Repository# and issue or pull request number

example: for the issue at https://github.com/aUser/user-repo/issues/23

use: aUser/user-repo#26

Organization

Organization_name/Repository# and issue or pull request number

example: for the issue at https://github.com/an-org/theirproject/issues/1000

use: an-org/theirproject#1000

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文