Gangmax Blog

自由之思想,独立之精神

Git Stash

| Comments

From here and here.

The “stash” command of Git is very useful when you want to save some temporary changes without making a commit, and use them later. Here some commands for typical scenarios.

1
2
3
4
5
6
7
8
9
10
11
12
13
# Add the current uncommitted changes into a "stash" with a given name:
git stash save 'Add fixed user pin to test'
# List the current "stashes":
git stash list
# Apply one "stash" in the stash list to the current code base:
git stash apply  # The top one.
git stash apply stash@{0}  # The one of the index number.
git stash apply stash\^{/Add}  # The one with the matched name to the given regex.
## Note that the above command is for "zsh" as described here: https://github.com/robbyrussell/oh-my-zsh/issues/449
## For "bash", use "git stash apply stash^{/Add}"
# Remove one "stash":
git stash drop  # The top one.
git stash drop stash@{1}  # The one of the index number.

Comments