我要如何使用Pull Request在GitHub上关闭一个问题?我知道可以通过提交信息来关闭多个问题,但这是不同的情况。
我想从Pull Request的描述中关闭问题,而不是从提交中。就像这样:
Pull Request:
Name: bla bla
Description ... , _fixes_ #123
在合并拉取请求时,能否自动关闭#123
?
我要如何使用Pull Request在GitHub上关闭一个问题?我知道可以通过提交信息来关闭多个问题,但这是不同的情况。
我想从Pull Request的描述中关闭问题,而不是从提交中。就像这样:
Pull Request:
Name: bla bla
Description ... , _fixes_ #123
在合并拉取请求时,能否自动关闭#123
?
作为你在评论中提到的内容, 从拉取请求合并后将会产生一个提交。
在这个提交信息中,您可以添加“close #xx
”来触发关闭问题。
然而,正如在“使用提交信息关闭Github中的多个问题”中所提到的,在GitHub博客文章“通过提交信息关闭问题"(2013年1月)和当前的GitHub文档中也有提到。
Now when you enter "
Fixes #33
" in a commit message, issue 33 will only be closed once the commit is merged into your default branch (usuallymaster
).This is super useful because it means the issue's open / closed status will map to your default branch.
If the bug isn't fixed in your default branch, the issue will remain open.
Once the commit with the fix is merged into your default branch the issue will be automatically closed.When you do make a commit in a non-default branch with the "
Fixes #33
" syntax, the issue will be referenced with a tooltip:
You can use any of these keywords to close an issue via commit message:
close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved
正如cosmolev(已点赞)所提到的,2013年5月14日发布的“通过拉取请求关闭问题”博客文章将拉取请求作为关闭问题的一种方式:
有些问题需要更多的工作才能关闭。
这就是为什么现在你可以通过拉取请求关闭问题。
你只需要在拉取请求的正文中包含特殊的关键词语法(例如 "fixes #5
"),即可完成操作。
当 PR 合并到默认分支时,引用的问题将自动关闭。
它甚至可以跨存储库使用。
正如约翰·艾肯贝里在评论中指出的那样,《使用关键词关闭问题》帮助页面确实提到:
要关闭多个问题,请在每个问题引用之前加上上述关键字之一。
您必须在引用每个问题之前使用关键字才能起作用。
例如,This closes #34, closes #23, and closes example_user/example_repo#42
将关闭同一存储库中的#34和#23问题以及“example_user/example_repo
” 存储库中的#42问题。
fixes #123, fixes #321, fixes #999
参考:https://help.github.com/en/articles/closing-issues-using-keywords - John Eikenberry终于可以了:https://github.com/blog/1506-closing-issues-via-pull-requests
只需在拉取请求消息中添加 resolve #18 ,其中18是问题编号。
merge
时,可以通过添加描述信息,如closes#123
或fixes#242#111
,来关闭拉取请求中的问题。其中#number == issue number
。请注意,这是在实际执行merge
操作时关闭问题,而不是在拉取请求上关闭问题。 - Andrei-Niculae Petre