⚡ ~/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 33 of 52 in Git & Branching Workflows
Senior DevOps / SRE [L2] Git .gitignore Production Scenario [L2]
🎯 Target Role / Context: Git Scenario #33 (L2) · .gitignore

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 500 MB blob is still in the object database, reachable from the old commit.

#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
⚡ 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: "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."

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 ...
⛔ 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 accidentally committed video 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 accidentally committed video 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 accidentally committed video 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 accidentally committed video 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 →