⚡ ~/naveed Interview Prep
⚡ Portfolio Home ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 998+ 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) →
Senior DevOps / SRE [L2] Git From your main checkout (on feature/new-api): Production Scenario [L2]

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 #From your main checkout (on feature/new-api): #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

🛠️ Production Runbook & Step-by-Step Resolution

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.
Advertisement
Want more Git scenarios?
Explore our complete collection of scenario-based Git interview runbooks.
Browse All Git Questions →

📚 Related Production Scenarios in Git