How to protect the "master" in github?

I have several members in my github project. I want to allow only one of them to "click" on the master. And this guy is not me (owner of the repository). Can this be done?

+40
git branch github protection acl
Apr 30 2018-12-12T00:
source share
3 answers

Then, when this question was submitted, GitHub did not allow you to specify branch level permissions. You can only do this at the repository level. So what you request was impossible.

If you want to get around this limitation, I personally see two options:

  • you could use some kind of commit commit, etc. to at least tell someone that something went wrong.
  • If you really need this tight control, you can use two repositories, one of which contains only your "leading" branch. Then you will need to make sure that only your "guy" gets write access to the main repository

I think it’s easier to solve with some organization. In my team, we never click anything on the master, but instead always create pull requests. This ensures that at least someone will look before the code is merged, and you can also define a policy that only your β€œguy” can combine traction requests.

Update

GitHub has now announced that they will be introducing a new feature called secure branches. This feature has been present in other git distributions such as Atlassian Stash for many years. This will allow you to protect some branches from tremors. However, it still does not fully protect individual branches based on ACLs. Thus, you can test this function in case you do not want to rely on an organizational solution, as shown above.

+33
May 22 '12 at 13:53
source share

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

  • against push
  • against removal
  • against merged changes until status checks pass

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




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

Sometimes merging with a secure branch is best left to the release manager or team of people responsible for the stability of that particular branch. Organizations can now specify which members and teams can click on a secure branch.

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

+9
Sep 03 '15 at 19:26
source share

This is exactly what forking was designed for. You will have a primary secure repository, and you are granting read permissions to this repository for all participants. These contributors will fork repos and push their changes to their personal copies of the main repo. When they are ready to enter the code into the main repository, they will send a transfer request to the main repo. In this case, the owners of the main project can fulfill the pull request.

+3
Feb 09 '15 at 2:32
source share



All Articles