⚡ ~/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 Stashing, Tags & Everyday Workflows Core Fundamentals [L1]

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 #Stashing, Tags & Everyday Workflows #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

🛠️ Production Runbook & Step-by-Step Resolution

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...
Advertisement
Want more Git scenarios?
Explore our complete collection of scenario-based Git interview runbooks.
Browse All Git Questions →

📚 Related Production Scenarios in Git