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 →
- Require a pull request with at least one approval, and dismiss stale approvals on new pushes.
- Require status checks (build, test, lint) and require branches to be up to date.
- Block force pushes and deletion.
- Require linear history or restrict merge types, as the team prefers.
- 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.
More on Protection, Hooks and Policy
Classic 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?IntermediateA developer bypasses your hook with `git commit --no-verify`. How do you enforce the rule anyway?Intermediate