git stash saves your current uncommitted work and reverts the working tree to HEAD.
git stash # stashes tracked changes
git stash -u # also stashes untracked files
git stash list # see all stashes
git stash pop # restore + remove top stash
git stash apply # restore but keep in stash list
git stash drop # delete one
git stash clear # delete all
Use cases:
- Pull cleanly when your tree is dirty:
git stash && git pull && git stash pop.
- Test what main looks like without your edits.
- Move WIP to another branch:
git stash && git switch other && git stash pop.
Stashes are local-only. They aren't pushed. They aren't part of any branch's history.