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.

Diagramgit stash Stack Diagram

IMAGE PROMPT (replace this block with your generated image):

Flat stack diagram on white background. Title: git stash โ€” Save and Restore Work in Progress. Left side: Working Directory box with three modified file icons (orange edit markers). Center: a vertical stack labeled Stash Stack (LIFO) with three stash entry cards stacked: stash@{0} (top, #3A5EFF fill, white text): WIP: half-finished payment form. stash@{1} (middle, lighter fill): WIP: navbar redesign. stash@{2} (bottom, lightest fill): WIP: database migration. Right side: a clean working directory box (green checkmark) labeled Clean โ€” can switch branches. Four command arrows around the stack: Top arrow into stack: git stash or git stash save "name". Arrow from stack top to right: git stash pop (removes from stack). Arrow from stack to right (dashed): git stash apply stash@{1} (keeps in stack). Arrow down-out: git stash drop / git stash clear. White background, brand color #3A5EFF for top stash entry and arrows.

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

Stashing Work in Progress โ€” Intermediate Git: Stashing, Tagging, Reverting, and Resetting โ€” Git and GitHub Complete Course: From Beginner to Advanced โ€” Script Valley โ€” Script Valley