Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict who can merge to master on a github repo?

Tags:

git

github

I have setup on my Github repo a branch protection rule on master branch checking (activating) the following:

  • Require pull request reviews before merging
  • Required approving reviewers : 1
  • Include administrators
  • Restrict who can push to matching branches

I'm then in a situation that at least one from the team must approve a PR before someone can merge its own dev branch to master.

Apart from the above I would also want to select only some people that will have the permission to merge the reviewed and approved PR. Not everyone having access to the repo.

Is it possible to set this up?

like image 743
koalaok Avatar asked Sep 01 '25 16:09

koalaok


2 Answers

No, GitHub doesn't let you restrict who can perform a merge. However, if you want to require a specific group of people to approve a PR before merging, use the CODEOWNERS file and require an approval from a code owner before merging in the branch protection settings.

For example, if you want all changes to be reviewed by the core team, you can use this in your CODEOWNERS file:

*  @my-org/core
like image 154
bk2204 Avatar answered Sep 04 '25 06:09

bk2204


Merging of pull requests respect the branch protection rule of the target branch. So add the people who should be allowed to merge into the protection rule and you are good to go.enter image description here

enter image description here

like image 40
ogborstad Avatar answered Sep 04 '25 05:09

ogborstad