You want to stop developers from committing obvious mistakes like debug prints, trailing whitespace or secrets.
BeginnerScenarioProtection, Hooks and Policy
Answer
Situation read → Catch issues before they hit the remote.
What I'd do →
- Add the
pre-commitframework with a.pre-commit-config.yaml(linters, formatters,detect-secretsorgitleaks). - Install the hooks:
pre-commit install. - Run the same checks in CI as a backstop.
Why → Local hooks give fast feedback, and CI catches anything that skipped them.
Interview tip → Hooks are advisory; developers can bypass with --no-verify.
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.IntermediateHooks in `.git/hooks` are not shared with the team. How do you distribute them?IntermediateA developer bypasses your hook with `git commit --no-verify`. How do you enforce the rule anyway?Intermediate