Stash on a Branch
Stash branch makes a branch from a stash. It is the tidy way to finish work you set aside.
Make a branch from the stash
The new branch starts where the stash was made. The stash drops itself.
$ git stash branch sugar-branchThe stash is gone
The list prints nothing. The stash became a branch.
$ git stash listExample
$ git stash branch sugar-branch
$ git statusKey points
- Stash branch with a name creates the branch at the stashโs base.
- It applies the stash onto the new branch.
- It drops the stash in the same step.
- The branch starts where the stash was made.
- Use it when the stash belongs on its own branch.
- The list is empty afterwards.
Here, the stash becomes a branch. The sugar change sits on it, unstaged, ready to finish.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does git stash branch do?