An approved PR gets a new commit just before merge. How do you prevent unreviewed code from slipping in?
IntermediateScenarioProtection, Hooks and Policy
Answer
Situation read → An approval should apply to the code that was reviewed.
What I'd do →
- Enable "Dismiss stale pull request approvals when new commits are pushed".
- Enable "Require approval of the most recent reviewable push" so the pusher cannot self-approve.
- Require review from Code Owners for sensitive paths.
Why → Otherwise a malicious or careless push after approval merges unchecked.
Interview tip → This is a common supply-chain control question.
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