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 stashThis 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 -uNaming a Stash
Give your stash a descriptive name for easier identification:
git stash save "WIP: half-finished payment form"Listing Stashes
git stash listThis 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.
