A developer bypasses your hook with `git commit --no-verify`. How do you enforce the rule anyway?
IntermediateScenarioProtection, Hooks and Policy
Answer
Situation read → Client-side hooks can never be trusted for enforcement.
What I'd do →
- Move the rule to CI and make that check required.
- Use server-side controls: rulesets (file path or size restrictions, commit message patterns) on GitHub.
- Keep hooks as fast feedback only.
- For self-hosted Git, a
pre-receivehook rejects bad pushes server-side.
Why → The server is the only place you control.
Interview tip → This distinction (client versus server enforcement) is a favourite interview question.
More on Protection, Hooks and Policy
You are asked to protect `main`. Which rules do you turn on?BeginnerClassic branch protection or repository rulesets: which do you use?IntermediateA required status check never reports and the PR is stuck as "Expected — Waiting for status".IntermediateProduction is down and the fix needs to merge now, but approvals are required.IntermediateYou want to stop developers from committing obvious mistakes like debug prints, trailing whitespace or secrets.BeginnerHooks in `.git/hooks` are not shared with the team. How do you distribute them?Intermediate