Does GitHub allow for pre-receive or update hooks?
What I would be looking to do is to prevent the primary branches from being pushed to (i.e. master, hotfix, develop) and require that they be merged via a GitHub pull request. This is a private repo so GitHub style forking is not an option.
Any advice on how to accomplish this would be of great help.
Your commits were rejected by the pre-receive hook of that repo (that's a user-configurable script that is intended to analyze incoming commits and decide if they are good enough to be accepted into the repo). It is also a good idea to ask that person to update the hook, so it would print the reasons for the rejection.
The pre-commit script is executed every time you run git commit before Git asks the developer for a commit message or generates a commit object. You can use this hook to inspect the snapshot that is about to be committed.
A pre-receive hook, like a pre-push hook, must read its standard input, one line at a time, checking each group of parameters supplied on that line. If the hook exits with a nonzero return, the entire push is rejected (from the server's side).
Only people that you have listed a 'collaborators' can push to a Github hosted repository. See the repository's 'admin' page to add collaborators. Everybody else needs to submit a 'pull request' to get their additions accepted by the repository's administrator. See Github Access Permissions. (There aren't per-branch access permissions.) So, in order to accomplish your goal, you don't need hooks; what you need is already built in.
Two Notes:
Though GitHub itself doesn't allow pre-receive hooks, GitHub Enterprise version 2.6 does include pre-receive hook support. More information about it can be found here: https://help.github.com/enterprise/admin/guides/developer-workflow/using-pre-receive-hooks-to-enforce-policy/. These are instance wide pre-receive hooks to prevent any information to be pushed into any repositories.
What I would be looking to do is to prevent the primary branches from being pushed to (i.e. master, hotfix, develop) and require that they be merged via a GitHub pull request.
However, to this point, you can configure GitHub or GitHub Enterprise repositories with protected branches. What this does is prevent the branch from being deleted, force pushed, only certain people or teams can merge, or a status check is required to be passing before a merge is allowable. Please see https://help.github.com/articles/about-protected-branches/ for more information!
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