Stash

Rationale

Use case: when you've already made some changes, but want to save the changes and apply them later. The reason for this could be you want to apply the changes to another branch.

Commands

  • git stash save the changes

    • git stash save "description" will add a description

  • git stash list show all stashes and their indeces

  • git stash show {stash-index} shows the stash specified by {stash-index}

  • git stash apply apply the last set of changes but keep the stash

    • git stash apply stash@{n} choose a stash to apply

  • git sttash pop similar to apply but removes the stash afterwards.

  • git stash drop {stash-index} removes a stash

  • git stash clear removes all stashes

Further reading Useful tricks you might not know about Git stash

Last updated