简体   繁体   English

如何用提交消息关闭GitHub拉取请求?

[英]How to close a GitHub pull request with a commit message?

My team uses pull requests internally for code-reviewing the application we maintain, but when it's time to merge a commit, we just push directly to master . 我的团队在内部使用pull请求来代码审查我们维护的应用程序,但是当合并提交时,我们只需直接推送到master We're all repo collabs anyway, and by not using the pull request to merge code, we avoid polluting our commit history with merge commits. 无论如何我们都是repo collabs,并且通过使用pull请求来合并代码,我们避免使用merge commit来污染我们的提交历史。 Since the app is internal to our team, no one else is affected. 由于该应用程序是我们团队的内部,因此没有其他人受到影响。

What I want to know is, can I amend my commit message with something like "closes PR #30" and have github automatically close the pull request for me? 我想知道的是,我可以用"closes PR #30"修改我的提交消息并让github自动关闭拉取请求吗?

I know you can use commit messages to close issues, so I'm hoping there is something similar for pull requests. 我知道你可以使用提交消息来关闭问题,所以我希望有类似的拉动请求。 I did a quick search online and of SO, and didn't see anything. 我在网上快速搜索了SO,但没有看到任何内容。

You probably want to look at this GitHub help page . 您可能想查看此GitHub帮助页面 It says: 它说:

You can use any of the following keywords to close an issue via commit message: 您可以使用以下任何关键字通过提交消息关闭问题:

  • close
  • closes 关闭
  • closed 关闭
  • fix 固定
  • fixes 修复
  • fixed 固定
  • resolve 解决
  • resolves 做出决议
  • resolved 解决

So "Fixes #123" or "Resolved #456" will work. 因此“修复#123”或“已解决#456”将起作用。 All pull requests are mapped as issues, so this will works for pull requests too. 所有拉取请求都被映射为问题,因此这也适用于拉取请求。

Note: you'll see a message about unmerged commits because you amended the pull request. 注意:您将看到有关未合并提交的消息,因为您修改了拉取请求。 So looking at the pull request, it won't be immediately obvious that the PR was incorporated (versus just plain closed) unless you put something meaningful in the first line of the commit message so you can see the message in the pull request. 因此,查看pull请求,除非您在提交消息的第一行中放置了有意义的内容,否则将PR合并(而不仅仅是普通关闭)并不是很明显,因此您可以在pull请求中看到消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM