8. Git Stash — Saving Work in Progress
Git Stash — Saving Work in Progress
You are halfway through a feature when your manager asks you to drop everything and fix an urgent bug in production. You can't commit half-finished code. You don't want to delete your changes. Git stash is a temporary shelf — it saves your incomplete work so you can switch contexts cleanly and come back later.
📦 Stashing and Restoring
Save all current uncommitted changes to the stash. Your working directory is now clean.
Switch to the urgent fix, apply it, commit, and push:
Return to your feature branch and restore your stashed work. Your half-finished code is back exactly as you left it:
📋 Managing Multiple Stashes
Stash with a descriptive message:
See all stashes:
Apply a specific stash (without removing it from the list):
Apply the most recent stash and remove it from the list:
Delete a stash you no longer need, or delete ALL stashes:
Knowledge Check
Ready to test your understanding of 8. Git Stash — Saving Work in Progress?