问题
We are a team of a few people. Everyone works on a feature branch and merges his stuff through GitHub UI into master
when one is ready.
Now is it possible to prevent direct pushes to master
, but instead create a pull request
whenever a new feature is ready to be merged? Additionally it would be awsome to restrict merges to a subset of devs only.
回答1:
Additionally it would be awsome to restrict merges to a subset of devs only.
You can restrict pushes to a branch in an Organization to specific users or teams. This will allow you to set up a team that can merge back into master
.

Alternatively, for a small team, you can consider having each developer set up client-side hooks to prevent pushing to a remote master
.
Lastly, if you use GitHub Enterprise that offers pre-receive hooks, you can enable one that enforces code to be merged through a PR
来源:https://stackoverflow.com/questions/34131617/how-to-protect-master-branch-in-github