Every commit message must reference a ticket such as `ABC-123`.
IntermediateScenarioProtection, Hooks and Policy
Answer
Situation read → Traceability is required for audits.
What I'd do →
- Local
commit-msghook:
#!/usr/bin/env bash
grep -qE '^(ABC|PLAT)-[0-9]+' "$1" || {
echo "Commit message must start with a ticket ID, e.g. ABC-123" >&2
exit 1
}
- With squash merges, validate the PR title in CI instead, since that becomes the commit message.
- Optionally add
prepare-commit-msgto prefill the ticket from the branch name.
Why → The check on PR title is enforceable, whereas the local hook is a convenience.
Interview tip → Say which of the two is authoritative.
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