I'd like to restrict write access to the master branch in a organization repository to its owner (namely me). This would enforce all contributors to make a branch instead of committing directly to master. If possible, I would also like to restrict access to approving pull requests to only me.

I did some research and came across GitHub protected branches, and I believe it might be the solution. But there are too many options to understand. The linked help page didn't help me either.

1 Answer 1


Yes, you will want to look into the Protected Branch settings.

If others need to do their work on another branch instead of working directly off master, check the following box:

Require pull request reviews before merging
When enabled, all commits must be made to a non-protected branch and submitted via a pull request with at least one approved review and no changes requested before it can be merged into master.

To then also limit who can approve it should be by selecting this checkbox:

Restrict who can push to matching branches
Specify people, teams or apps allowed to push to matching branches. Required status checks will still prevent these people, teams and apps from merging if the checks fail.

By default that will restrict it to admins only. If the repo has other admins listed then you'll want to get that sorted out because the included owners are:

Organization and repository administrators - These members can always push.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.