Skip to main content

How to Use git stash?

· One min read
Xiaohai Huang

git stash with a stash name.

git stash push -m "stash_name"

stash untracked files

git stash push -u -m "stash_name"
git stash push --include-untracked -m "stash_name"

show stash list

xiaohai@DESKTOP-CO17DMM:~/projects/learning-notes$ git stash list
stash@{0}: On search-engine-week1: search-engine-notes
stash@{1}: On AI-week1: AI-week1-stash

apply stash through index

git stash apply stash@{1}

delete a stash

git stash drop            # drop top hash, stash@{0}
git stash drop stash@{n} # drop specific stash - see git stash list