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?
To find it go to Settings > Branches > Branch Protection Rules and click 'Add Rule'. Then, enter the name of the branch you want to protect and click the checkbox to require pull request reviews before merging.
Back then, when this question was posted, GitHub didn't allow you to specify access privileges on a branch level. You can only do it on a repository level. So what you are requesting wasn't possible.
If you want to work around this limitation, I personally see two options:
I think it is easier to solve that with some organisation. In my team, we never push anything directly to master, but instead always create pull requests. That ensures that at least someone takes a look before code gets merged and you could also define a policy that only your "guy" is allowed to merge pull requests.
Update
GitHub now announced that they will roll-out a new feature called protected branches. This feature has been present in other git distributions like Atlassian Stash for years. It will allow you to protect some branches from pushes. However, it still doesn't allow complete ACL-based protection of individual branches. So you might want to check this feature out in case you don't want to rely on an organizational solution as outline above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With