Git & GitHub·Fix and recover

Stashing work

Park unfinished changes, switch context and come back without committing half a feature.

Beginner 11 min read Lesson 9 of 480 Challenge included
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.

stash.shTerminal
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"
CommandResult
git stash push -uInclude untracked files
git stash listShow the stash stack
git stash popApply and remove the newest stash
git stash apply stash@{n}Apply without removing
git stash drop stash@{n}Delete one stash
Your turn

Park work and restore it

Medium

Stash the current changes with a message, switch to main, then come back and pop the stash.

BASH · starter
# your commands here
Check 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 in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Merging and conflicts
Lesson 9 of 480 · 0% of course