⚡ ~/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 21 of 52 in Git & Branching Workflows
Junior / Associate DevOps [L1] Git Stashing, Tags & Everyday Workflows Core Fundamentals [L1]
🎯 Target Role / Context: Git Scenario #21 (L1) · Stashing, Tags & Everyday Workflows

Q: You're halfway through coding a feature when an urgent bug report comes in. You need to switch branches immediately, but your changes aren't ready to commit. How do you save your in-progress work?

Use git stash to save your uncommitted changes onto a stack without committing them:

#Git #L1 #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: Practical understanding of git stash and its usage patterns.. 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: Practical understanding of git stash and its usage patterns.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."

1️⃣

Initial Diagnostics & Root Cause Analysis

Use git stash to save your uncommitted changes onto a stack without committing them:

  • git stash saves both staged and unstaged changes to tracked files. Untracked files are not stashed by default — add -u (or --include-untracked) to include them. Add -a to also include ignored files.
  • git stash list shows all stashes. They're numbered stash@{0}, stash@{1}, etc.
  • git stash pop applies the most recent stash and removes it from the stack. git stash apply applies it but keeps it on the stack — safer if you want to apply the same stash to multiple branches.
2️⃣

Remediation & Permanent Safeguards

Key details: Don't use stash as long-term storage — stashes are easy to forget. If the work will sit for more than a few hours, commit it on a throwaway branch instead.

git stash push -m "WIP: user profile feature"
git switch hotfix/critical-bug
# ... fix the bug, commit, push ...
git switch feature/user-profile
git stash pop
  • git stash drop stash@{2} removes a specific stash. git stash clear removes all.
  • You can create a branch directly from a stash: git stash branch new-branch stash@{0} — useful if the stash conflicts with current work.
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: git stash saves both staged and unstaged changes to tracked files. Untracked files are not stashed by default — add -u (or --inclu."
⚡ 60-Second Elevator Pitch Talking Points
  • git stash saves both staged and unstaged changes to tracked files. Untracked files are not stashe...
  • git stash list shows all stashes. They're numbered stash@{0}, stash@{1}, etc.
  • git stash pop applies the most recent stash and removes it from the stack. git stash apply applie...
⛔ 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 Youre halfway coding 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 Youre halfway coding 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 Youre halfway coding 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 Youre halfway coding 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 →