Skip to content

Stash

In one line

Stashing temporarily saves your uncommitted changes in a stack, cleaning your working directory so you can switch context.

In simple words

git stash shelves your uncommitted changes (both staged and unstaged) and restores the working directory to the last committed state. The changes are saved in a stash stack and can be restored later with git stash pop.

Stashing is the solution to "I am in the middle of something but I need to switch branches urgently." Instead of committing half-finished work (which creates a junk commit), you stash it, switch branches, do what you need, switch back, and pop the stash to resume.

You can have multiple stashes in a stack. git stash list shows all stashes, git stash apply restores without removing, git stash drop removes without restoring, and git stash pop does both (apply + drop).

Example

bash
# Stash current work
git stash

# Switch branches and do something urgent
git checkout main
# ... fix a bug ...
git checkout feature

# Restore your stashed work
git stash pop

Stash saves changes temporarily; pop restores them.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary