我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

将拉取请求链接到议题

You can link a pull request to an issue to show that a fix is in progress and to automatically close the issue when the pull request is merged.

本文内容

此文档对您有帮助吗?

帮助我们创建出色的文档!

所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。

做出贡献

或, 了解如何参与。

Note: The special keywords in a pull request description are interpreted when the pull request targets the repository's default branch. However, if the PR's base is any other branch, then these keywords are ignored, no links are created and merging the PR has no effect on the issues. If you want to link a pull request to an issue using a keyword, the PR must be on the default branch.

关于链接的议题和拉取请求

You can link an issue to a pull request using a supported keyword in the pull request description.

当您将拉取请求链接到拉取请求指向的议题,如果有人正在操作该议题,协作者可以看到。 If the pull request and the issue are in different repositories, GitHub Enterprise will display the link after the pull request is merged, if the person who merges the pull request also has permission to close the issue.

将链接的拉取请求合并到仓库的默认分支时,其链接的议题将自动关闭。 For more information about the default branch, see "Changing the default branch."

使用关键词将拉取请求链接到议题

You can link a pull request to an issue by using a supported keyword in the pull request's description or in a commit message (please note that the pull request must be on the default branch).

  • close
  • closes
  • closed
  • fix
  • fixes
  • fixed
  • 解决
  • resolves
  • resolved

关闭关键词的语法取决于议题是否与拉取请求在同一仓库中。

链接的议题语法示例
同一仓库中的议题KEYWORD #ISSUE-NUMBERCloses #10
不同仓库中的议题KEYWORD OWNER/REPOSITORY#ISSUE-NUMBERFixes octo-org/octo-repo#100
多个议题对每个议题使用完整语法Resolves #10, resolves #123, resolves octo-org/octo-repo#100

您也可以在提交消息中使用关闭关键词。 The issue will be closed when you merge the commit into the default branch, but the pull request that contains the commit will not be listed as a linked pull request.

延伸阅读

此文档对您有帮助吗?

帮助我们创建出色的文档!

所有 GitHub 文档都是开源的。看到错误或不清楚的内容了吗?提交拉取请求。

做出贡献

或, 了解如何参与。