git 在提交消息中链接到 GitHub 上的问题编号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1687262/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Link to the issue number on GitHub within a commit message
提问by Mika Tuupola
Is it somehow possible to automaticallyhave a link to GitHub issue number in the git commit
message?
是否有可能在消息中自动包含指向 GitHub 问题编号的链接git commit
?
回答by NARKOZ
Just include #xxx
in your commit message to reference an issue without closing it.
只需#xxx
在您的提交消息中包含以引用问题而不关闭它。
With new GitHub issues 2.0you can use these synonyms to reference an issue and closeit (in your commit message):
在新的GitHub 问题 2.0 中,您可以使用这些同义词来引用问题并关闭它(在您的提交消息中):
fix #xxx
fixes #xxx
fixed #xxx
close #xxx
closes #xxx
closed #xxx
resolve #xxx
resolves #xxx
resolved #xxx
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
.
您也可以替代#xxx
使用gh-xxx
。
Referencing and closing issues across reposalso works:
fixes user/repo#xxx
Check out the documentationavailable in their Help section.
查看他们的帮助部分中可用的文档。
回答by mipadi
If you want to link to a GitHub issue andclose the issue, you can provide the following lines in your Git commit message:
如果要链接到 GitHub 问题并关闭该问题,可以在 Git 提交消息中提供以下几行:
Closes #1.
Closes GH-1.
Closes gh-1.
(Any of the three will work.) Note that this will link to the issue and also closeit. You can find out more in this blog post(start watching the embedded video at about 1:40).
(这三个中的任何一个都可以。)请注意,这将链接到问题并关闭它。您可以在这篇博文中找到更多信息(从大约 1:40 开始观看嵌入的视频)。
I'm not sure if a similar syntax will simply link to an issue without closing it.
我不确定类似的语法是否会简单地链接到一个问题而不关闭它。
回答by narkeeso
You can also cross reference repos:
您还可以交叉引用存储库:
githubuser/repository#xxx
xxx being the issue number
xxx 是问题编号
回答by Henrik Lindberg
github adds a reference to the commit if it contains #issuenbr (discovered this by chance).
如果提交包含#issuenbr(偶然发现),github 会添加对提交的引用。
回答by xero
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/
他们在他们的博客https://github.blog/2011-04-09-issues-2-0-the-next-generation/上写了一篇关于新问题 2.0 的好文章
synonyms include
同义词包括
- fixes #xxx
- fixed #xxx
- fix #xxx
- closes #xxx
- close #xxx
- closed #xxx
- 修复#xxx
- 固定#xxx
- 修复#xxx
- 关闭#xxx
- 关闭#xxx
- 关闭#xxx
using any of the keywords in a commit message will make your commit either mentioned or close an issue.
在提交消息中使用任何关键字都会使您的提交被提及或关闭问题。
回答by Suhas Srivats Subburathinam
In order to link the issue number to your commit message, you should add:
#issue_number
in your git commit message.
为了将问题编号链接到您的提交消息,您应该添加:
#issue_number
在您的 git 提交消息中。
Example Commit Message fromUdacity Git Commit Message Style Guide
来自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
You can also reference the repositories:
您还可以参考存储库:
githubuser/repository#issue_number
回答by Bananeweizen
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 Eclipsefor 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.
就像对其他答案的补充一样:如果您甚至不想用问题编号编写提交消息并且碰巧使用Eclipse进行开发,那么您可以安装 eGit 和 Mylyn 插件以及 Mylyn 的 GitHub 连接器。然后 Eclipse 可以自动跟踪您正在处理的问题并自动填写提交消息,包括所有其他答案中显示的问题编号。
For more details about that setup see http://wiki.eclipse.org/EGit/GitHub/UserGuide
有关该设置的更多详细信息,请参阅http://wiki.eclipse.org/EGit/GitHub/UserGuide
回答by omnikron
One of my first projects as a programmer was a gem called stagecoachthat (among other things) allowed the automaticadding 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.
我作为程序员的第一个项目是一个名为stagecoach的 gem ,它(除其他外)允许将github 问题编号自动添加到分支上的每个提交消息,这是尚未真正回答的问题的一部分.
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 hookthat appended the issue number to the commit message automatically.
基本上,在创建分支时,您将使用自定义命令(类似于stagecoach -b <branch_name> -g <issue_number>
),然后将问题编号分配给 yml 文件中的该分支。然后有一个提交钩子,自动将问题编号附加到提交消息。
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.
我不会推荐它用于生产用途,因为当时我只编程了几个月并且不再维护它,但有人可能会对它感兴趣。