What is the purpose of 'pre-receive hooks' in GitHub Enterprise Server?
Select an answer to reveal the explanation.
Short Explanation and Infographic
Pre-receive hooks are GHES's custom policy enforcement engine on the server side. Write a script, deploy it to GHES, and it runs every time someone tries to push — you can reject commits that don't meet your standards before they even land.
Full explanation below image
Full Explanation
GitHub Enterprise Server pre-receive hooks are server-side scripts that execute on the GHES instance before Git accepts a push. If the script exits with a non-zero status, the push is rejected and the error message is returned to the user. Use cases include: (1) Enforcing commit message format (Jira ticket references, conventional commits). (2) Preventing pushes that contain certain file types or sizes. (3) Enforcing code signing requirements. (4) Validating that certain metadata is included. Pre-receive hooks are configured by GHES site administrators and can be applied globally, per organization, or per repository. They are different from client-side Git hooks (local to each developer's machine) and from webhooks (triggered after events, not before). Only available on GHES — not GitHub.com or GHEC.