git stash

Practice git stash from memory. git stash pushes local changes onto the stash stack so you can work on something else. git stash pop re-applies the most

Save dirty working tree state to the stash and restore HEAD.

git stash

git stash pushes local changes onto the stash stack so you can work on something else. git stash pop re-applies the most recent stash.

Safety: Inspect first and avoid rewriting shared history unless the team expects it.

Apply the most recent stash and remove it from the stash list.

git stash pop

pop applies the top stash and removes it from the stack. If the apply conflicts, the stash stays - fix conflicts, then git stash drop manually.

Safety: Inspect first and avoid rewriting shared history unless the team expects it.

Show all saved stash entries.

git stash list

Shows the stash stack with indexes (stash@{0} is newest). Pair with git stash show -p stash@{N} to preview what's in a specific entry before applying.

Safety: Inspect first and avoid rewriting shared history unless the team expects it.

Apply a specific stash entry without removing it.

git stash apply stash@{1}

stash apply re-applies the stash but leaves it in the list. Use stash pop to apply and remove.

Safety: Inspect first and avoid rewriting shared history unless the team expects it.

Delete the most recent stash entry from the stash list.

git stash drop stash@{0}

drop deletes a stash entry without applying it. stash@{0} is the most recent; omit the ref to drop the top of the stack.

Safety: Inspect first and avoid rewriting shared history unless the team expects it.

Create a new branch from a stash entry and apply it.

git stash branch fix/wip stash@{0}

Creates fix/wip from the commit the stash was based on, then applies the stash there. Useful when a stash conflicts with the current branch - replays cleanly on its origin.

Safety: Inspect first and avoid rewriting shared history unless the team expects it.

Build the habit: GitDrill drills git stash and the rest of the Git workflow until the safe first move is automatic. Try a Git drill.