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

You are asked to protect `main`. Which rules do you turn on?

BeginnerScenarioProtection, Hooks and Policy
Answer

Situation read → The aim is that nothing reaches main without review and passing checks.

What I'd do →

  1. Require a pull request with at least one approval, and dismiss stale approvals on new pushes.
  2. Require status checks (build, test, lint) and require branches to be up to date.
  3. Block force pushes and deletion.
  4. Require linear history or restrict merge types, as the team prefers.
  5. Apply rules to administrators too.

Why → Rules that admins can skip protect against nothing during a rushed Friday deploy.

Interview tip → Mention CODEOWNERS for sensitive paths.

All Git & GitHub questions Roadmap: Git & GitHub

More on Protection, Hooks and Policy