git stash pop: Usage, Options & Common CI Errors
git stash pop reapplies your most recent stash and drops it from the stack on success.
Pop is apply-then-drop in one step. The subtlety automation must handle: on a conflict, pop reapplies the changes but keeps the stash entry, so the stack is not actually cleaned up.
What it does
git stash pop applies the changes from a stash entry (the latest by default) back onto the working tree, then deletes that entry - but only if the apply succeeds without conflicts.
Common usage
git stash pop
git stash pop stash@{2}
git stash pop --index # also restore the staged/unstaged split
git stash list # confirm the stackOptions
| Flag | What it does |
|---|---|
| [<stash>] | Pop a specific entry (default: stash@{0}) |
| --index | Restore index state too, not just the worktree |
| -q / --quiet | Suppress output |
Common errors in CI
On conflict, pop prints "The stash entry is kept in case you need it again" and exits non-zero - the entry stays on the stack. Resolve, git add, then git stash drop manually. "No stash entries found" also exits non-zero; guard pop in scripts that may run with an empty stack.