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

启用必需状态检查

在拉取请求中合并分支之前,或可以将本地分支上的提交推送到受保护远程分支之前,仓库管理员可以实施所需状态检查。

受保护分支适用于具有 GitHub Free 的公共仓库,以及具有 GitHub Pro、GitHub Team、GitHub Enterprise Cloud 及 GitHub Enterprise Server 的公共和私有仓库。 For more information, see "GitHub's products."

You can automatically enforce protected branch settings for some or all branches in your repository. 更多信息请参阅“配置受保护分支”。

Before you can enable required status checks, you must configure the repository to use the status API. For more information, see "Building a CI Server" in GitHub 开发者文档.

  1. On GitHub, navigate to the main page of the repository.

  2. Under your repository name, click Settings.

    Repository settings button

  3. In the left menu, click Branches.

    Repository options sub-menu

  4. Next to "Branch protection rules", click Add rule.

    Add branch protection rule button

  5. Under "Branch name pattern", type the branch name or pattern you want to protect.

    Branch rule field

  6. Under "Protect matching branches", select Require status checks to pass before merging.

    必需状态检查选项

  7. Optionally, select Require branches to be up to date before merging. 如果选中,则可确保使用基础分支上的最新代码来测试分支。

    宽松或严格的必需状态复选框

  8. From the list of available status checks, select the checks you want to require.

    可用状态检查列表

  9. 视情况可选择 Include administrators(包括管理员)。 This enforces all configured restrictions for repository administrators.

    包括管理员复选框

  10. 单击 Save changes(保存更改)

Tip: To successfully merge a pull request into a base branch that has required status checks enabled, the pull request's head branch must be up-to-date with the base branch.

问问别人

找不到要找的内容?

联系我们