Interview Prep/Git & GitHub/Protection, Hooks and Policy

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 →

  1. Move the rule to CI and make that check required.
  2. Use server-side controls: rulesets (file path or size restrictions, commit message patterns) on GitHub.
  3. Keep hooks as fast feedback only.
  4. For self-hosted Git, a pre-receive hook 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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Protection, Hooks and Policy