Stashing work
Park unfinished changes, switch context and come back without committing half a feature.
What you will be able to do
- Stash tracked and untracked files
- Inspect and apply stashes
- Drop what you no longer need
A stash saves your dirty working tree on a stack so you can switch branches or pull cleanly. Apply it later and continue exactly where you stopped.
git stash push -m "wip: hero section"
git stash list
git switch main
git switch feature/hero
git stash pop
git stash apply stash@{1}
git stash drop stash@{1}
git stash push -u -m "wip with new files"| Command | Result |
|---|---|
| git stash push -u | Include untracked files |
| git stash list | Show the stash stack |
| git stash pop | Apply and remove the newest stash |
| git stash apply stash@{n} | Apply without removing |
| git stash drop stash@{n} | Delete one stash |
Your turn
MediumPark work and restore it
Stash the current changes with a message, switch to main, then come back and pop the stash.
BASH · starter
# your commands hereCheck your understanding before moving on.
Knowledge checkQuestion 1
What is the difference between stash pop and stash apply?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.