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

启用分支限制

You can enforce branch restrictions so that only certain users, teams, or apps can push to a protected branch in repositories owned by your organization.

受保护分支适用于具有 GitHub Free 的公共仓库,以及具有 GitHub Pro、GitHub Team、GitHub Enterprise Cloud 及 GitHub Enterprise Server 的公共和私有仓库。 限制分支是一种适用于组织在 GitHub Team、GitHub Enterprise Cloud 及 GitHub Enterprise Server 中拥有的公共和私有仓库的保护。 For more information, see "GitHub's products."

Anyone with admin permissions to an organization-owned repository can enable branch restrictions.

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

  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. 视情况可选择 Include administrators(包括管理员)。 This enforces all configured restrictions for repository administrators.

    包括管理员复选框

  7. Under "Protect matching branches", select Restrict who can push to matching branches.

    分支限制复选框

  8. 搜索并选择将有权推送到受保护分支的用户、团队或应用。

    分支限制搜索

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

延伸阅读

问问别人

找不到要找的内容?

联系我们