Stashing temporarily saves uncommitted changes without committing them. Use it when you need to switch branches but do not want to commit your current work, or to clean your working directory before pulling. Stashes are local and private—they are not shared with remotes or other team members.
Create a stash with git stash (or git stash push with a message). Your working directory becomes clean, and your changes are saved in a stack. Later, restore with git stash pop, which applies the changes and removes the stash. If you want to keep the stash, use git stash apply instead. View all stashes with git stash list.
$ git stash # save uncommitted changes $ git stash push -m "desc" # save with a description $ git stash pop # restore the most recent stash $ git stash apply <stash> # apply a specific stash without removing it $ git stash list # view all stashes $ git stash drop <stash> # delete a stash
Stashes are useful for quick context switches, but don't rely on them for long-term storage—they are easy to lose if you accidentally push a new stash without checking if you have unsaved work. If you have a stash that matters, either pop it soon or commit it to a temporary branch so you do not lose it.