在提交消息中链接到GitHub上的问题编号

Mik*_*ola 712 git github git-commit

是否有可能在消息中自动获得指向GitHub问题编号的链接git commit

NAR*_*KOZ 909

只需#xxx在提交消息中包含引用问题而不关闭它.

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

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

您也可以替代#xxx使用gh-xxx.

在repos中引用和关闭问题也有效:

fixes user/repo#xxx
Run Code Online (Sandbox Code Playgroud)

查看其"帮助"部分中提供的文档.

  • 这些也不区分大小写.`修复#xxx`也有效. (86认同)
  • @Dennis删除"问题"一词 (16认同)
  • "修复问题#xxx"不适合我,任何想法?它引用了该问题,但没有关闭它. (4认同)
  • 我不会成为将这个答案从 666 票移到 667 票的人,但这非常有帮助。 (3认同)
  • 为我工作。我对此唯一能说的是,当我看到 xxx 时,我认为它是一个 3 位数字,但显然“fixes #9”例如会起作用。如果答案明确表明它适用于任何长度的数字并且不需要用零填充,那就太好了。 (3认同)

mip*_*adi 164

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

Closes #1.
Closes GH-1.
Closes gh-1.
Run Code Online (Sandbox Code Playgroud)

(这三个中的任何一个都可以工作.)请注意,这将链接到该问题并关闭它.你可以在这篇博文中找到更多信息(大约1:40开始观看嵌入式视频).

我不确定类似的语法是否只是链接到一个问题而不关闭它.

  • 您只需使用问题编号(例如#456)就可以在不关闭任务的情况下链接到任务. (30认同)
  • 我会选择"gh-1"而不是"#1",因为你永远不知道存储库是否被导出/镜像到github以外的某个地方.然后,"#1"没有多大意义. (9认同)
  • @mipadi:是否需要"关闭GH-1"之后的`.`?还有,区​​分大小写吗? (2认同)

nar*_*eso 64

您还可以交叉引用回购:

githubuser/repository#xxx
Run Code Online (Sandbox Code Playgroud)

xxx是问题编号


小智 61

如果github包含#issuenbr(偶然发现),则会添加对提交的引用.

  • 只是测试它,就像一个魅力,谢谢...这是一个应该被标记为正确的答案...... (4认同)
  • 这应该是已接受答案的一部分。有时您只是想提及该问题,但尚未采取任何措施。 (3认同)

xer*_*ero 14

他们在他们的博客上写了关于新问题2.0的一篇很好的文章 https://github.com/blog/831-issues-2-0-the-next-generation

同义词包括

  • 修复了#xxx
  • 固定#xxx
  • 修复#xxx
  • 关闭#xxx
  • 关闭#xxx
  • 关闭#xxx

使用提交消息中的任何关键字将使您的提交提及或关闭问题.


Suh*_*nam 12

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

来自 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
Run Code Online (Sandbox Code Playgroud)

您还可以参考存储库:

githubuser/repository#issue_number
Run Code Online (Sandbox Code Playgroud)


Ban*_*zen 5

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

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


omn*_*ron 5

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

基本上,在创建分支时,您将使用自定义命令(类似于stagecoach -b <branch_name> -g <issue_number>),然后将问题编号分配给 yml 文件中的该分支。然后有一个提交钩子,自动将问题编号附加到提交消息。

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