⚡ ~/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 .gitignore Production Scenario [L2]

Q: You accidentally committed a 500 MB video file three commits ago. The file was deleted in a later commit, but the repo is still huge. Why, and how do you actually remove it?

Deleting a file in a new commit does not remove it from history. Git stores every version of every file as an immutable blob object. The ...

#Git #.gitignore #L2 #Version Control #Collaboration
🎙️ Candidate Opening & Architectural Context
""In a fast-paced team with dozens of pull requests merged daily, Git workflow hygiene was critical. The interviewer is testing: Understanding of Git's object model and history rewriting for large files.. 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

Deleting a file in a new commit does not remove it from history. Git stores every version of every file as an immutable blob object. The 500 MB blob is still in the object database, reachable from the old commit. Every clone downloads it.

  • Force-push all branches: git push --force --all && git push --force --tags.
  • Every teammate must re-clone (or git fetch origin && git reset --hard origin/main). Their old local commits reference the rewritten SHAs and will cause confusion.
  • GitHub/GitLab may still cache the old objects — contact support to trigger garbage collection on the server, or wait for the platform's scheduled GC.
2️⃣

Remediation & Permanent Safeguards

Finding the large objects: Or use git-sizer for a comprehensive report. Removing the file from all history: The modern tool is git filter-repo (replaces the deprecated git filter-branch): This rewrites every commit that ever contained big-video.mp4, removing the file entirely. All commit SHAs from that point onward change. After rewriting: Prevention: set up Git LFS for large binaries, and add a pre-receive hook or CI check that rejects files above a size threshold.

git rev-list --objects --all | \
  git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | \
  sed -n 's/^blob //p' | sort -rnk2 | head -20
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Force-push all branches: git push --force --all && git push --force --tags.."
⚡ 60-Second Elevator Pitch Talking Points
  • Force-push all branches: git push --force --all && git push --force --tags.
  • Every teammate must re-clone (or git fetch origin && git reset --hard origin/main). Their old loc...
  • GitHub/GitLab may still cache the old objects — contact support to trigger garbage collection on ...
Advertisement
Want more Git scenarios?
Explore our complete collection of scenario-based Git interview runbooks.
Browse All Git Questions →

📚 Related Production Scenarios in Git