'How to protect "master" in github?

I have a few contributors in my github project. I want to allow only one of them to "push" to master. And this guy is not me (the owner of the repository). Is it possible to do?



Solution 1:[1]

Note: Protected branches and required status checks (September 3, 2015) will allow you to protect a branch

  • against forced pushed
  • against deletion
  • against merged changes until required status checks pass

https://cloud.githubusercontent.com/assets/25792/9596474/27db3ce6-502a-11e5-9b19-5b47a8addc65.png


Since March 2016, as commented by Sander below, you have User and team restrictions

Sometimes merges to a protected branch are best left to a release manager or a team of people responsible for the stability of that particular branch. Organizations can now specify which members and teams are able to push to a protected branch.

https://cloud.githubusercontent.com/assets/4719/14140705/ed98abac-f67a-11e5-951e-b48c842fb77f.png

Solution 2:[2]

This is exactly what forking was designed for. You would have the main repository protected, and you would allow read permissions on that repository for all contributors. Those contributors would fork the repo, and would push their changes to their personal copies of the main repo. When they are ready to introduce code into the main repository, they would submit a pull request into the main repo. In this case, owners of the main project could complete the pull request.

Solution 3:[3]

We can now use "CODEOWNERS" file to Require review from Code Owners to valid a pull request. We can set different permissions based on their GitHub account.

see here and here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 kbuilds
Solution 3 Malick