๐ŸŽ“ A1Learner
๐Ÿ”
0 of 50 lessons completed

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-branch

The stash is gone

The list prints nothing. The stash became a branch.

$ git stash list

Example

$ git stash branch sugar-branch
$ git status

Key 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?