提交消息中指向 GitHub 上问题编号的链接

发布于 2024-08-11 02:39:50 字数 79 浏览 9 评论 0原文

是否可以在 git commit 消息中自动拥有指向 GitHub 问题编号的链接?

Is it somehow possible to automatically have a link to GitHub issue number in the git commit message?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(8

站稳脚跟 2024-08-18 02:39:50

只需在提交消息中包含 #xxx 即可引用问题,而无需关闭它。

使用新的 GitHub issues 2.0 您可以使用这些同义词引用问题并关闭(在提交消息中):

  • fix #xxx
  • fixes #xxx
  • 固定#xxx
  • 关闭#xxx
  • 关闭#xxx
  • 关闭#xxx
  • 解决#xxx
  • resolves #xxx
  • resolved #xxx

您还可以将 #xxx 替换为 gh-xxx

引用和跨存储库关闭问题也有效:

fixes user/repo#xxx

查看< a href="https://help.github.com/en/articles/looking-issues-using-keywords" rel="noreferrer">文档可在其“帮助”部分中找到。

Just include #xxx in your commit message to reference an issue without closing it.

With new GitHub issues 2.0 you can use these synonyms to reference an issue and close it (in your commit message):

  • fix #xxx
  • fixes #xxx
  • fixed #xxx
  • close #xxx
  • closes #xxx
  • closed #xxx
  • resolve #xxx
  • resolves #xxx
  • resolved #xxx

You can also substitute #xxx with gh-xxx.

Referencing and closing issues across repos also works:

fixes user/repo#xxx

Check out the documentation available in their Help section.

你的往事 2024-08-18 02:39:50

如果您想链接到 GitHub 问题关闭该问题,您可以在 Git 提交消息中提供以下行:(

Closes #1.
Closes GH-1.
Closes gh-1.

三者中的任何一个都可以。)请注意,这将链接到该问题并且关闭它。您可以在这篇博客文章中了解更多信息(开始观看嵌入式视频时间约为 1:40)。

我不确定类似的语法是否会简单地链接到问题而不关闭它。

If you want to link to a GitHub issue and close the issue, you can provide the following lines in your Git commit message:

Closes #1.
Closes GH-1.
Closes gh-1.

(Any of the three will work.) Note that this will link to the issue and also close it. You can find out more in this blog post (start watching the embedded video at about 1:40).

I'm not sure if a similar syntax will simply link to an issue without closing it.

乖乖哒 2024-08-18 02:39:50

github 添加对包含 #issuenbr 的提交的引用(偶然发现的)。

github adds a reference to the commit if it contains #issuenbr (discovered this by chance).

掩于岁月 2024-08-18 02:39:50

您还可以交叉引用存储库:

githubuser/repository#xxx

xxx 是问题编号

You can also cross reference repos:

githubuser/repository#xxx

xxx being the issue number

错爱 2024-08-18 02:39:50

他们在博客上写了一篇关于新问题 2.0 的精彩文章
https://github.blog/2011-04- 09-issues-2-0-the-next- Generation/

同义词包括

  • fixes #xxx
  • fix #xxx
  • fix #xxx
  • closes #xxx
  • close #xxx
  • close #xxx

在提交消息中使用任何关键字都会使您的提交提到的问题或关闭问题。

they have an nice write up about the new issues 2.0 on their blog
https://github.blog/2011-04-09-issues-2-0-the-next-generation/

synonyms include

  • fixes #xxx
  • fixed #xxx
  • fix #xxx
  • closes #xxx
  • close #xxx
  • closed #xxx

using any of the keywords in a commit message will make your commit either mentioned or close an issue.

冰雪梦之恋 2024-08-18 02:39:50

为了将问题编号链接到您的提交消息,您应该添加:
git 提交消息中的 #issue_number

提交消息示例 Udacity Git 提交消息风格指南

feat: Summarize changes in around 50 characters or less

More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of the commit and the rest of the text as the body. The
blank line separating the summary from the body is critical (unless
you omit the body entirely); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.

Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequenses of this
change? Here's the place to explain them.

Further paragraphs come after blank lines.

 - Bullet points are okay, too

 - Typically a hyphen or asterisk is used for the bullet, preceded
   by a single space, with blank lines in between, but conventions
   vary here

If you use an issue tracker, put references to them at the bottom,
like this:

Resolves: #123
See also: #456, #789

您还可以参考存储库:

githubuser/repository#issue_number

In order to link the issue number to your commit message, you should add:
#issue_number in your git commit message.

Example Commit Message from Udacity Git Commit Message Style Guide

feat: Summarize changes in around 50 characters or less

More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of the commit and the rest of the text as the body. The
blank line separating the summary from the body is critical (unless
you omit the body entirely); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.

Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequenses of this
change? Here's the place to explain them.

Further paragraphs come after blank lines.

 - Bullet points are okay, too

 - Typically a hyphen or asterisk is used for the bullet, preceded
   by a single space, with blank lines in between, but conventions
   vary here

If you use an issue tracker, put references to them at the bottom,
like this:

Resolves: #123
See also: #456, #789

You can also reference the repositories:

githubuser/repository#issue_number
甜是你 2024-08-18 02:39:50

正如其他答案的补充:如果您甚至不想编写带有问题编号的提交消息并且碰巧使用 Eclipse 进行开发,那么您也可以安装 eGit 和 Mylyn 插件作为 Mylyn 的 GitHub 连接器。然后,Eclipse 可以自动跟踪您正在处理的问题,并自动填写提交消息,包括所有其他答案中显示的问题编号。

有关该设置的更多详细信息,请参阅 http://wiki.eclipse.org/EGit/GitHub/UserGuide< /a>

Just as addition to the other answers: If you don't even want to write the commit message with the issue number and happen to use Eclipse for development, then you can install the eGit and Mylyn plugins as well as the GitHub connector for Mylyn. Eclipse can then automatically track which issue you are working on and automatically fill the commit message, including the issue number as shown in all the other answers.

For more details about that setup see http://wiki.eclipse.org/EGit/GitHub/UserGuide

仄言 2024-08-18 02:39:50

作为一名程序员,我的第一个项目是一个名为 stagecoach 的 gem,它(除其他外)允许 自动将 github 问题号添加到分支上的每个提交消息中,这是尚未真正得到解答的问题的一部分。

本质上,在创建分支时,您将使用自定义命令(例如 stagecoach -b-g),然后将问题编号分配给该分支yml 文件。然后有一个 commit hook 附加了问题编号自动提交消息。

我不会推荐它用于生产用途,因为当时我只编程了几个月,我不再维护它,但有人可能会对它感兴趣。

One of my first projects as a programmer was a gem called stagecoach that (among other things) allowed the automatic adding of a github issue number to every commit message on a branch, which is a part of the question that hasn't really been answered.

Essentially when creating a branch you'd use a custom command (something like stagecoach -b <branch_name> -g <issue_number>), and the issue number would then be assigned to that branch in a yml file. There was then a commit hook that appended the issue number to the commit message automatically.

I wouldn't recommend it for production use as at the time I'd only been programming for a few months and I no longer maintain it, but it may be of interest to somebody.

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