Git Stash and Work Restoration Commands Guide

Temporary Storage and Work Restoration

git stash - Temporarily Save Work

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 temporarily
git stash push -m "WIP: feature implementation" - Save changes with a message
git stash list - Display a list of saved changes
git stash show - Display a summary of the latest saved changes
git stash show -p - Display details of the latest saved changes
git stash apply - Apply the latest saved changes (remains in stack)
git stash pop - Apply the latest saved changes and remove from stack
git stash drop stash@{2} - Delete specific saved changes
git stash clear - Delete all saved changes
git stash branch new-branch - Create a new branch and apply saved changes to it