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

You want tests to run before every push.

BeginnerScenarioProtection, Hooks and Policy
Answer

Situation read → Catching failures before CI saves round trips.

What I'd do →

  1. Create .githooks/pre-push, make it executable (chmod +x).
  2. Run a fast subset: lint plus unit tests, not the full suite.
  3. Exit non-zero to block the push.
  4. Allow skipping when needed with git push --no-verify, knowing CI still checks.

Why → If the hook takes minutes, people bypass it. Keep it under ten or so seconds.

Interview tip → Fast hooks get used; slow hooks get disabled.

All Git & GitHub questions Roadmap: Git & GitHub

More on Protection, Hooks and Policy