book-git-commands/src/stashing.md

652 B

Stashing changes

# If you can't pull/merge due to a file conflict, stashes changes, does a pull, and then puts the changes back, dropping the stash.
# git stash pop = git stash apply && git stash drop
git stash
git pull
git stash pop

# Stash changes and then apply them, keeping the stash.
git stash
git pull
git stash apply

# Drop the most recent stash.
git stash drop

# View all Stashes in a pretty list.
git stash list --pretty=format:'%Cblue%gd%Cred: %C(yellow)%s'

# Show file changes in a particular stash (0 = last one).
git stash show 'stash@{0}'

# Show individual changes in a particular stash.
git stash show -p 'stash@{0}'