Algocraft / Git Commands / git stash

🧳

git stash

Shelve uncommitted changes onto a stack, get a clean working directory, then bring them back whenever you're ready

Stash Stack pop vs apply
Commit Graph Step 0 / 0
Working Directory → Staging → Repository
Terminal Transcript

Key Concepts

🎯 When to Use
  • An urgent bug lands mid-feature and you need a clean branch fast
  • You want to pull the latest main without committing half-done work
⚖️ Pop vs Apply
  • pop: re-apply and remove it from the stack
  • apply: re-apply but keep it on the stack too
  • Stashes are a stack — the newest one applies first
🎓 Pro Tips
  • git stash list shows everything currently shelved
  • git stash pop can conflict just like a merge if the branch moved on
  • A forgotten stash isn't lost — but it's easy to forget it's there