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

Classic branch protection or repository rulesets: which do you use?

IntermediateScenarioProtection, Hooks and Policy
Answer

Situation read → Both enforce rules, but rulesets are the newer, more flexible system.

What I'd do →

  1. Prefer rulesets: they target branches and tags by pattern, can be layered, and support org-wide rules.
  2. Use "evaluate" mode to test a ruleset before enforcing it.
  3. Use bypass lists for specific roles, apps or teams, with an audit trail.
  4. Migrate gradually; where both apply, the most restrictive result wins.

Why → Rulesets avoid copy-pasting protection per repo and give visibility into who can bypass.

Interview tip → Say "rulesets are layered and additive".

All Git & GitHub questions Roadmap: Git & GitHub

More on Protection, Hooks and Policy