Chapter 11 of 14All chapters
Chapter 11 of 14
Stashing
Putting work aside for a moment.
Save and restore
git stash takes your uncommitted changes, saves them and leaves a clean working tree. git stash pop puts them back when you return.
- git stash list shows what you have parked, oldest last.
- Add -u to include untracked files, which are otherwise left behind.
When to use it
Stashing suits a quick interruption: a hotfix on another branch, or pulling when your tree is dirty. For anything longer, a commit on a branch is safer than a stash you will forget.