⚡ ~/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) →
Junior / Associate DevOps [L1] Git ... fix the bug, commit, push ... Core Fundamentals [L1]

Q: You committed with the wrong message — or forgot to add a file to the last commit. How do you fix it without creating a new commit?

Use git commit --amend:

#Git #... fix the bug, commit, push ... #L1 #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: `--amend` usage and awareness of its implications.. 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

Use git commit --amend:

  • Fix the message only:
  • Add a forgotten file to the last commit:
2️⃣

Remediation & Permanent Safeguards

--amend replaces the last commit with a new one (new SHA). The old commit becomes orphaned and will be garbage-collected eventually. Critical rule: only amend commits that haven't been pushed. If you've already pushed, amending requires a force-push, which rewrites shared history. For pushed commits, create a follow-up commit instead, or use --force-with-lease on your own feature branch if the team agrees.

git commit --amend -m "Correct commit message"
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Fix the message only:."
⚡ 60-Second Elevator Pitch Talking Points
  • Fix the message only:
  • Add a forgotten file to the last commit:
Advertisement
Want more Git scenarios?
Explore our complete collection of scenario-based Git interview runbooks.
Browse All Git Questions →

📚 Related Production Scenarios in Git