A regulator asks who changed branch protection settings and when.
AdvancedScenarioProtection, Hooks and Policy
Answer
Situation read → You need an audit trail outside Git.
What I'd do →
- Query the organisation audit log (UI, or
gh api /orgs/ORG/audit-logon Enterprise Cloud) filtering for ruleset and protection events. - Stream audit logs to your SIEM for long-term retention.
- Store protection config as code (Terraform
github_repository_ruleset) so changes are PR-reviewed. - Alert on bypass events and ruleset edits.
Why → Config as code gives history, review and rollback for the controls themselves.
Interview tip → Say "protect the protections" — admins who can change rules can undo any control.
More on Protection, Hooks and Policy
You are asked to protect `main`. Which rules do you turn on?BeginnerClassic 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?Intermediate