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 →
- Create
.githooks/pre-push, make it executable (chmod +x). - Run a fast subset: lint plus unit tests, not the full suite.
- Exit non-zero to block the push.
- 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.
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