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 →
- Prefer rulesets: they target branches and tags by pattern, can be layered, and support org-wide rules.
- Use "evaluate" mode to test a ruleset before enforcing it.
- Use bypass lists for specific roles, apps or teams, with an audit trail.
- 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".
More on Protection, Hooks and Policy
You are asked to protect `main`. Which rules do you turn on?BeginnerA 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