Stash Your Work
Stash puts unfinished changes aside. It cleans the tree so you can switch branches, then brings the changes back later.
Put the work aside
The sugar line is unfinished. The stash holds it for later.
$ git stash push -m "sugar line in progress"The tree is clean
Nothing is left in the files. The branch is safe to leave.
$ git statusSee the saved stash
One stash waits in the list, with its message.
$ git stash listExample
$ git stash push -m "sugar line in progress"
$ git stash listKey points
- Stash with push saves the changes and cleans the tree.
- A message names the stash, so you can find it later.
- The stash list shows every stash you saved.
- Stashes live outside any branch.
- Switch branches freely while the work waits in the stash.
- Stash only when the tree is dirty. A clean tree needs no stash.
Here, one stash holds the sugar line. The tree is clean, so the branch is safe to leave.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does stash do?