- [[git branch]]
# Idea
Use stash when you don't want to commit any experimental changes. You "stash away" some changes that you don't need or want right now, but you think you might want them in the future.
It saves your local/uncommitted changes (stashes them away) and reverts the working tree to match the `HEAD` commit. That is, it will stash away any changes you've made since your last commit.
Stashes are carried over from branch to branch.
```sh
# save uncommitted changes in a stash—removes changes from working tree!
# git will assign a random id
git stash
# save with a message
git stash save "did something stupid"
# list stashes
git stash list
# apply the most recent stash to working tree
git stash apply
# apply/retrieve uncommitted changes where x is 0,1,2...
git stash apply stash@{x}
# apply and remove the most recent stash
git stash pop
# apply a stash and remove it from stash list
git stash pop stash@{x}
# remove the most recent stash
git stash drop
# remove specific sttash
git stash drop stash@{x}
# remove all stashes
git stash clear
```
# References
- https://stackoverflow.com/questions/20537223/what-is-the-intended-use-case-for-git-stash
- https://www.youtube.com/watch?v=KLEDKgMmbBI