Temporarily saves current work and cleans the working directory.
Subcommand/Option | Description |
---|---|
push [message] | Save changes temporarily (message is optional) |
list | Display a list of saved changes |
show [stash@{n}] | Display the content of saved changes |
apply [stash@{n}] | Apply saved changes (without removing from stack) |
pop [stash@{n}] | Apply saved changes and remove from stack |
drop [stash@{n}] | Delete saved changes |
clear | Delete all saved changes |
-u, --include-untracked | Include untracked files in the stash |
-a, --all | Include all files, including ignored ones |
Examples:
git stash
- Save current changes temporarilygit stash push -m "WIP: feature implementation"
- Save changes with a messagegit stash list
- Display a list of saved changesgit stash show
- Display a summary of the latest saved changesgit stash show -p
- Display details of the latest saved changesgit stash apply
- Apply the latest saved changes (remains in stack)git stash pop
- Apply the latest saved changes and remove from stackgit stash drop stash@{2}
- Delete specific saved changesgit stash clear
- Delete all saved changesgit stash branch new-branch
- Create a new branch and apply saved changes to it