⚡ ~/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 27 of 52 in Git & Branching Workflows
Senior DevOps / SRE [L2] Git From your main checkout (on feature/new-api): Production Scenario [L2]
🎯 Target Role / Context: Git Scenario #27 (L2) · From your main checkout (on feature/new-api):

Q: You need to find out who last changed a specific line in a file, when they changed it, and why. Walk me through how you'd investigate.

Start with git blame:

#Git #L2 #Version Control #Collaboration
🎙️ Candidate Opening & Architectural Context
""During a major release branch cut, we encountered this exact scenario and used Git internals to recover cleanly. The interviewer is testing: git blame, git log for a specific line range, and investigation workflow.. 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: "During a major release branch cut, we encountered this exact scenario and used Git internals to recover cleanly. The interviewer is testing: git blame, git log for a specific line range, and investigation workflow.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."

1️⃣

Initial Diagnostics & Root Cause Analysis

Start with git blame:

  • git blame --ignore-rev skips a known bulk-formatting commit. Create a .git-blame-ignore-revs file listing such commits and configure it globally.
  • git blame -w ignores whitespace changes.
  • git blame -C detects code moved or copied from other files.
2️⃣

Remediation & Permanent Safeguards

This shows the commit SHA, author, date, and content for line 42. The -L flag limits output to specific lines (-L 40,50 for a range). To understand *why* the change was made: If the blame shows a commit like "Apply formatting" (not the real author), dig deeper: This blames the file at the commit *before* the formatting change. Or use git log -L 42,42:src/auth/login.js to see the full history of changes to that specific line range — every commit that touched those lines, with diffs. For files that have been renamed, add --follow: Pro tips:

git blame -L 42,42 src/auth/login.js
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: git blame --ignore-rev skips a known bulk-formatting commit. Create a .git-blame-ignore-revs file listing such commits and config."
⚡ 60-Second Elevator Pitch Talking Points
  • git blame --ignore-rev skips a known bulk-formatting commit. Create a .git-blame-ignore-revs fil...
  • git blame -w ignores whitespace changes.
  • git blame -C detects code moved or copied from other files.
⛔ 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 need find last 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 need find last 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 need find last 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 need find last 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 →