如何限制团队成员将他们在分支存储库中所做的更改合并到基本存储库?

How to restrict team members from merging the changes that they did in there forked repository to base repository?

我已经创建了一个基本存储库并向我的朋友发送了成为我项目的合作者的请求。他分叉了我的存储库并在那里做了一些更改。然后他创建了一个拉取请求,让我合并他所做的更改。但与此同时,他还可以选择在未经我许可的情况下将更改合并到基本存储库,即我的存储库。我如何限制它?我的意思是如何只能合并请求而不是我的所有团队成员。

实际上,我已经在一台电脑上试过了,我在浏览器上打开了主账户,在隐身选项卡上打开了另一个账户。并创建了从我的另一个帐户到主帐户的拉取请求,但在我的另一个帐户中,我可以选择将更改合并到我的主帐户的基本存储库,当我这样做时,更改会反映到我的主帐户 GitHub存储库也。

帮我修一下。如果我哪里错了然后告诉我我的朋友只能创建拉取请求的过程,我会在检查后合并它们。

首先检查您的目标分支(用作合并请求的目标的分支)是如何受到保护的。

参见“About protected branches", more precisely "Defining the mergeability of pull requests

你可以强制“required reviews for pull request

Repository administrators can require that all pull requests receive a specific number of approving reviews from:

  • people with write or admin permissions in the repository
  • or from a designated code owner before they're merged into a protected branch.

关于模式,文档提到:

You can create a branch rule in a repository for a specific branch, all branches, or any branch that matches a naming pattern specified with the fnmatch syntax.
For example, to require any branch containing the word release to have at least two pull request reviews before merging, you can create a branch rule for *release*.

您可以看到 fnmatch pattern here 的示例。
模式匹配的完整规范在 here, which leads to Patterns Matching a Single Character and Multiple Characters.

要保护存储库 GitHub 页面上的分支:

  1. 打开右上角的设置选项卡
  2. 单击 left-hand 列中的 分支机构
  3. Select 您想要 protect/restrict 访问的分支
  4. 分支保护规则右侧单击添加规则
  5. 分支名称模式字段是您要保护的分支的确切名称。
  6. select 合并前需要拉取请求审查 或 select 需要代码所有者审查
  7. 单击底部的绿色 创建 按钮即可完成!