【发布时间】:2010-12-13 19:44:04
【问题描述】:
是否有可能自动在git commit 消息中提供指向 GitHub 问题编号的链接?
【问题讨论】:
标签: git github git-commit
是否有可能自动在git commit 消息中提供指向 GitHub 问题编号的链接?
【问题讨论】:
标签: git github git-commit
只需在您的提交消息中包含 #xxx 即可引用问题而无需关闭它。
有了新的GitHub issues 2.0,你可以使用这些同义词来reference an issue and close它(在你的提交信息中):
fix #xxxfixes #xxxfixed #xxxclose #xxxcloses #xxxclosed #xxxresolve #xxxresolves #xxxresolved #xxx您也可以将#xxx 替换为gh-xxx。
引用和closing issues across repos 也可以:
fixes user/repo#xxx
查看“帮助”部分中的the documentation。
【讨论】:
Fix issue #xxx 对我不起作用,有什么想法吗?它引用了这个问题,但没有关闭它。
dev 的分支上工作时,这对我不起作用。
如果您想链接到 GitHub 问题并关闭该问题,您可以在 Git 提交消息中提供以下行:
Closes #1.
Closes GH-1.
Closes gh-1.
(这三个中的任何一个都可以。)请注意,这将链接到问题并关闭它。您可以在此blog post 中了解更多信息(大约 1:40 开始观看嵌入视频)。
我不确定类似的语法是否会简单地链接到一个问题而不关闭它。
【讨论】:
. 是否必要?另外,它是否区分大小写?
message (closes GH-28) 对我有用,不确定是否所有内容都不区分大小写。
如果提交包含#issuenbr(偶然发现),github 会添加对提交的引用。
【讨论】:
你也可以交叉引用repos:
githubuser/repository#xxx
xxx 是问题编号
【讨论】:
他们在博客上写了一篇关于新问题 2.0 的精彩文章 https://github.blog/2011-04-09-issues-2-0-the-next-generation/
同义词包括
在提交消息中使用任何关键字都会使您的提交被提及或关闭问题。
【讨论】:
为了将问题编号链接到您的提交消息,您应该添加:
#issue_number 在您的 git 提交消息中。
示例提交消息来自 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
您也可以参考存储库:
githubuser/repository#issue_number
【讨论】:
feat 比refactor 更常用,而且refactor 也没有明显的缩写(ref 可能意味着参考,rf 太不清楚了,等)。
就像其他答案一样:如果您甚至不想使用问题编号编写提交消息并且碰巧使用 Eclipse 进行开发,那么您可以安装 eGit 和 Mylyn插件以及 Mylyn 的 GitHub 连接器。然后 Eclipse 可以自动跟踪您正在处理的问题并自动填写提交消息,包括所有其他答案中显示的问题编号。
有关该设置的更多详细信息,请参阅http://wiki.eclipse.org/EGit/GitHub/UserGuide
【讨论】:
作为程序员,我的第一个项目是一个名为 stagecoach 的 gem,它(除其他外)允许自动将 github 问题编号添加到分支上的每个提交消息中,即尚未真正回答的问题的一部分。
基本上,在创建分支时,您会使用自定义命令(类似于stagecoach -b <branch_name> -g <issue_number>),然后问题编号将在 yml 文件中分配给该分支。然后有一个commit hook 自动将问题编号附加到提交消息中。
我不建议将它用于生产用途,因为当时我只编程了几个月并且不再维护它,但它可能会引起某些人的兴趣。
【讨论】: