Published on

Git Stash

Authors
  • avatar
    Name
    Gene Zhang
    Twitter

git stash temporarily shelves (or stashes) changes you've made to your working copy so you can work on something else, and then come back and re-apply them later on.

Stash

Stash all changes:

git stash

Stash one file:

git stash push -m "Stash myfile" -- myfile.txt

The -- separator is used when:

  1. Disambiguating between a file and a branch name (if a file has the same name as a branch).
  2. Ensuring arguments are interpreted as filenames rather than options.

List

git stash list

Apply

git stash pop

or

git stash apply
git stash apply stash@{1}