Skip to Content
DevopsGitGit WorkflowGit Stash

Basic Usage

Save your current changes:

Terminal
# save the modified files, and revert the working directory to the last commit. git stash # To include untracked files git stash -u
Git stash

Apply Stashed Changes

To restore the most recent stash:

Terminal
# restore the saved changes, and remove the Stash from the Stash list git stash pop # restore the saved changes, and Apply Without Removing the Stash git stash apply
Git stash

commands for create a stash

git stash push

Add a message:

Terminal
git stash push -m "WIP: login feature"

git stash list

Show all stashes:

Terminal
git stash list

Example output:

stash@{0}: WIP on main: login fix stash@{1}: WIP on feature: navbar changes

git stash show

Show summary of changes in a stash:

Terminal
git stash show stash@{0}

Show full diff:

Terminal
git stash show -p stash@{0}

Apply specific stash

Terminal
git stash apply stash@{2}

git stash drop

Delete a stash:

Terminal
git stash drop stash@{0}

git stash clear

Delete all stashes:

Terminal
git stash clear
Last updated on