提交消息中指向 GitHub 上问题编号的链接
是否可以在 git commit
消息中自动拥有指向 GitHub 问题编号的链接?
Is it somehow possible to automatically have a link to GitHub issue number in the git commit
message?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
只需在提交消息中包含
#xxx
即可引用问题,而无需关闭它。使用新的 GitHub issues 2.0 您可以使用这些同义词引用问题并关闭(在提交消息中):
fix #xxx
fixes #xxx
固定#xxx
关闭#xxx
关闭#xxx
关闭#xxx
解决#xxx
resolves #xxx
resolved #xxx
您还可以将
#xxx
替换为gh-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
withgh-xxx
.Referencing and closing issues across repos also works:
Check out the documentation available in their Help section.
如果您想链接到 GitHub 问题并关闭该问题,您可以在 Git 提交消息中提供以下行:(
三者中的任何一个都可以。)请注意,这将链接到该问题并且关闭它。您可以在这篇博客文章中了解更多信息(开始观看嵌入式视频时间约为 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:
(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.
github 添加对包含 #issuenbr 的提交的引用(偶然发现的)。
github adds a reference to the commit if it contains #issuenbr (discovered this by chance).
您还可以交叉引用存储库:
xxx 是问题编号
You can also cross reference repos:
xxx being the issue number
他们在博客上写了一篇关于新问题 2.0 的精彩文章
https://github.blog/2011-04- 09-issues-2-0-the-next- Generation/
同义词包括
在提交消息中使用任何关键字都会使您的提交提到的问题或关闭问题。
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
using any of the keywords in a commit message will make your commit either mentioned or close an issue.
为了将问题编号链接到您的提交消息,您应该添加:
git 提交消息中的
#issue_number
。提交消息示例 Udacity Git 提交消息风格指南
您还可以参考存储库:
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
You can also reference the repositories:
正如其他答案的补充:如果您甚至不想编写带有问题编号的提交消息并且碰巧使用 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
作为一名程序员,我的第一个项目是一个名为 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.