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

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 →

  1. Local commit-msg hook:
#!/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
}
  1. With squash merges, validate the PR title in CI instead, since that becomes the commit message.
  2. Optionally add prepare-commit-msg to 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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Protection, Hooks and Policy