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

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 →

  1. Add the pre-commit framework with a .pre-commit-config.yaml (linters, formatters, detect-secrets or gitleaks).
  2. Install the hooks: pre-commit install.
  3. 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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Protection, Hooks and Policy