⚡ ~/naveed Interview Prep
⚡ Portfolio Home 👤 About Naveed Bio & Credentials 📫 Contact Naveed Get In Touch ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
← Back to All Git & Branching Workflows Interview Questions Scenario 20 of 52 in Git & Branching Workflows
Staff SRE / Principal Architect [L3] Git Advanced Staff SRE Scenario [L3]
🎯 Target Role / Context: Git Scenario #20 (L3) · Advanced

Q: Design a branch-protection and merge-policy setup for a regulated environment (PCI / SOC 2) with 30 services in a monorepo. Walk me through the controls you'd put on `main` and how they interact with developer ergonomics.

Compliance auditors essentially want to see: every change to main is reviewed by someone other than the author, every change is traced to a ticket, every change runs the same controls, and the history is tamper-evident.

#Git #Advanced #L3 #Version Control #Collaboration #Rebase
🎙️ Candidate Opening & Architectural Context
""Git is an immutable directed acyclic graph (DAG); knowing commands like git reflog means you never truly lose commits. The interviewer is testing: Holistic policy design balancing compliance, security, and velocity.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third.""
Advertisement
⚡ Recommended Practice Lab

Want to master this scenario in a live sandbox? KodeKloud's Advanced Git Workflows, Rebase & Interactive Diagnostics covers this exact problem with hands-on terminal drills.

🛠️ Production Runbook & Step-by-Step Resolution

Direct Answer: "Git is an immutable directed acyclic graph (DAG); knowing commands like git reflog means you never truly lose commits. The interviewer is testing: Holistic policy design balancing compliance, security, and velocity.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."

1️⃣

Initial Diagnostics & Root Cause Analysis

Compliance auditors essentially want to see: every change to main is reviewed by someone other than the author, every change is traced to a ticket, every change runs the same controls, and the history is tamper-evident.

  • No direct pushes — pushes only via PR. Restrict who can push to matching branches set to no one (not even admins, with Do not allow bypassing enabled).
  • Linear history required — no merge commits. Forces squash- or rebase-merge, making each main commit a single reviewable, revertable unit.
  • Required reviews — minimum 1 for low-risk paths, 2 for sensitive paths via CODEOWNERS. Dismiss stale reviews on new commits so a reviewer's approval doesn't carry over after the author force-pushes.
  • CODEOWNERS mapping critical paths (/infra/, /auth/, /billing/, /.github/workflows/) to specific owners. Workflows-on-workflows is a common attack vector — protect .github/ aggressively.
  • Required status checks — CI must pass: unit tests, integration tests, SAST (e.g. Semgrep), dependency scan (Dependabot/Snyk/Trivy), secret scan (gitleaks), license scan, and the duplicate-Q&A or contract-tests if relevant. Pin the exact check names so they can't be renamed away.
  • Signed commits required — see prior answer.
  • Conversation resolution required — every PR comment must be resolved before merge.
  • No bypass for admins — auditors will ask. The tradeoff: a real emergency (rare) requires temporarily lifting the rule, which is logged in the audit trail and is itself a finding to triage.
  • Ticket linking — PR title regex enforced to include JIRA-1234 (or similar). The commit-msg hook on the server rejects PRs without it. Auditors get traceability from ticket → PR → commit → deployment.
2️⃣

Remediation & Permanent Safeguards

Controls on main: Process controls layered on top: Where this hits ergonomics: The principle: make the secure path the easy path. If the protected workflow is faster than circumventing it (because of good tooling, fast CI, and sane PR sizes), engineers stays on it; the policy then enforces itself culturally rather than only via lockdown.

  • PR templates — checkboxes for "tests added," "security impact considered," "rollback plan." Required for sensitive areas via CODEOWNERS-driven PR templates.
  • Production deploy gating — main is continuously deployed to staging, but production promotion goes through a separate change-management workflow (ServiceNow, Linear, etc.) with the deploying engineer different from the commit author. Many auditors require this segregation of duties.
  • Audit log retention — Git host audit logs (GitHub Enterprise, GitLab Premium) retained 1+ year and shipped to your SIEM. The audit log captures every protection-rule change, force-push attempt, and admin override.
  • Two reviewers required on /auth/ slows urgent fixes — mitigate with a documented break-glass process and clear on-call ownership.
  • Required signed commits adds setup friction for new hires — build it into the laptop bootstrap script and have the onboarding checklist verify a signed test commit before they get repo write access.
  • Many required checks → slow merges. Invest in CI parallelism and selective testing (run only the affected service's tests when paths under services/foo/ change). Without this, developers will route around the system, defeating the policy.
  • "No bypass for admins" feels paranoid until you're sitting in a SOC 2 audit; lean into it and design the emergency process upfront so engineers know what to do without disabling controls.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: No direct pushes — pushes only via PR. Restrict who can push to matching branches set to no one (not even admins, with Do not allo."
⚡ 60-Second Elevator Pitch Talking Points
  • No direct pushes — pushes only via PR. Restrict who can push to matching branches set to no one (...
  • Linear history required — no merge commits. Forces squash- or rebase-merge, making each main comm...
  • Required reviews — minimum 1 for low-risk paths, 2 for sensitive paths via CODEOWNERS. Dismiss st...
⛔ Critical Candidate Mistakes to Avoid in This Scenario

Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:

  1. Running raw git push --force rather than git push --force-with-lease on shared team feature branches when configuring Design branch protection git push --force unconditionally overwrites remote commits made by teammates, whereas --force-with-lease aborts if the remote ref was updated.
  2. Resolving complex merge conflicts with blind checkout overwrite strategies without running unit tests when configuring Design branch protection Unilateral conflict resolution frequently clobbers complementary logic introduced in parallel feature branches, creating regression bugs.
  3. Discarding corrupted working directories prematurely instead of recovering lost state using git reflog when configuring Design branch protection git reflog tracks every HEAD movement, allowing instant recovery of discarded commits, botched rebases, or deleted local branches.
  4. Disabling branch protection rules and mandatory PR approval reviews on shared release branches when configuring Design branch protection Without branch protection, developers can bypass CI validation gates and push untested code directly to production branches.
Advertisement
Want more Git & Branching Workflows scenarios?
Explore our complete collection of scenario-based Git & Branching Workflows interview runbooks.
Browse All Git & Branching Workflows Questions →