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

Q: What is `git fsck` and when would you use it?

git fsck (file system check) verifies the integrity of the Git object database — it walks every object and checks that nothing is corrupted, missing, or orphaned.

#Git #L2 #Version Control #Collaboration #Rebase
🎙️ Candidate Opening & Architectural Context
""When an engineer accidentally creates this branch or commit divergence, I walk them through safe recovery without data loss. The interviewer is testing: Knowledge of Git's integrity checking and disaster recovery.. 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: "When an engineer accidentally creates this branch or commit divergence, I walk them through safe recovery without data loss. The interviewer is testing: Knowledge of Git's integrity checking and disaster recovery.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."

1️⃣

Initial Diagnostics & Root Cause Analysis

git fsck (file system check) verifies the integrity of the Git object database — it walks every object and checks that nothing is corrupted, missing, or orphaned.

  • Every object's SHA matches its content (detects corruption).
  • Every commit's parent exists.
  • Every tree's referenced blobs and sub-trees exist.
  • No invalid object types or malformed headers.
  • dangling commit — a commit not reachable from any branch or tag. Often from amended commits, rebases, or deleted branches. Harmless; git gc cleans them up.
  • dangling blob — file content not referenced by any tree. Usually from staged-but-uncommitted files.
2️⃣

Remediation & Permanent Safeguards

What it checks: What it reports: When to use it: Recovery from corruption: if fsck reports missing objects, try re-fetching from the remote (git fetch origin). If the remote has the objects, they'll fill the gaps. For truly lost objects, restore from a backup or re-clone.

git fsck --full
  • missing object — an object referenced but not found. This is actual corruption.
  • broken link — a tree or commit references an object that doesn't exist.
  • After a disk failure or unclean shutdown — verify the repo isn't corrupted.
  • Recovering lost commits — git fsck --unreachable lists orphaned commits you might want to rescue (alternative to reflog).
  • Debugging weird Git errors — "fatal: bad object" errors often point to corruption that fsck can diagnose.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: Every object's SHA matches its content (detects corruption).."
⚡ 60-Second Elevator Pitch Talking Points
  • Every object's SHA matches its content (detects corruption).
  • Every commit's parent exists.
  • Every tree's referenced blobs and sub-trees exist.
⛔ 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 fsck 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 fsck 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 fsck 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 fsck 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 →