Git stash
git Stash Basics
Git stash allows you to store some file changes temporarily without having to commit the work. This is often needed when changing to another branch while having un-committed changes in the current branch.
Quick stash
To quickly stash some changes, run git stash. You can then come back to this branch later and run git stash pop to bring back your changes.
Note, that by default, pop will only bring back the last stashed changes
View list of stashes
Run git stash list to see a list of the stashes on the current branch.
Name stashes
To name a stash, run git stash save "<message>" and give it a description for your stash so that you can easily retrieve it later, or if you wanted to have multiple stashes.
Retrieve
To retrieve a specific stash, run git stash pop stash@{#} where # is the stash number you want. This will remove the stash from the list and apply it in your current branch.
To apply a stash but keep the stash, run git stash apply stash@{#}
Delete a specific stash
To delete a specific stash, run git stash drop stash@{n} where n is the the stash number you want to drop.
Misc notes
- add
-uflag to also stash untracked files - add
-aflag to also track ignored files