Script Valley
Git and GitHub Complete Course: From Beginner to Advanced
Intermediate Git: Stashing, Tagging, Reverting, and ResettingLesson 4.1

Stashing Work in Progress

git stash, git stash pop, git stash list, git stash apply, stash named, stash with untracked files

Stashing Work in Progress

Stashing lets you temporarily save uncommitted changes so you can switch context without committing incomplete work. It is essential when you need to quickly fix a bug on another branch while in the middle of a feature.

Basic Stash

git stash

This saves all staged and unstaged changes to a stash and restores your working directory to the last commit. Your changes are not lost — they are stored in a temporary stack.

Stashing Untracked Files

By default, git stash only saves tracked files. To also stash untracked files:

git stash -u

Naming a Stash

Give your stash a descriptive name for easier identification:

git stash save "WIP: half-finished payment form"

Listing Stashes

git stash list

This shows all stashes with their index numbers, like stash@{0}, stash@{1}.

Applying and Popping Stashes

git stash pop applies the most recent stash and removes it from the stash list. git stash apply stash@{1} applies a specific stash but keeps it in the list — useful when you want to apply the same stash to multiple branches.

Dropping a Stash

git stash drop stash@{0}

Remove a specific stash from the list. Use git stash clear to remove all stashes at once.

Up next

Tagging Releases

Sign in to track progress