Temporarily shelve uncommitted changes and restore them later — use when you need to switch context without committing
Save uncommitted work temporarily without creating a commit.
git stash push -u -m "WIP: description"git stash pop# Stash all changes (tracked files)
git stash
# Stash with message (always do this)
git stash push -m "WIP: auth refactoring"
# Include untracked files
git stash -u
# Include everything (untracked + ignored)
git stash -a
# Stash only specific files
git stash push -m "stash auth" src/auth.js
# Stash only staged changes
git stash push --staged
# List stashes
git stash list
# Show stash contents
git stash show -p # latest
git stash show -p stash@{2} # specific
# Apply and remove from stack
git stash pop
# Apply and keep in stack
git stash apply
# Apply specific stash
git stash pop stash@{2}
# Drop a stash
git stash drop stash@{0}
# Clear all stashes
git stash clear
# Create branch from stash (avoids conflicts)
git stash branch new-branch
-m message — naked stashes are impossible to identify later-u to include untracked — new files are silently left behind otherwisegit stash dropgit stash branch <name> to apply on original commitgit fsck --no-reflog | grep commit may find itgit stash apply works on any branch