Skip to content
Latchkey

git stash: Usage, Options & Common CI Errors

git stash tucks away your uncommitted changes so you get a clean working tree, then brings them back later.

Stash is handy for parking work mid-task. In automation, watch for conflicts when popping.

What it does

git stash records the current state of the working tree and index on a stack and reverts to a clean HEAD. git stash pop reapplies the most recent entry and removes it from the stack.

Common usage

Terminal
git stash                     # stash tracked changes
git stash push -u             # include untracked files
git stash push -m "wip" path/ # stash a subset with a label
git stash list
git stash pop                 # reapply + drop
git stash apply               # reapply, keep on stack

Options

FlagWhat it does
push -u / --include-untrackedAlso stash untracked files
push -a / --allAlso stash ignored files
popReapply and drop the latest stash
applyReapply but keep the stash
drop / clearRemove one / all stash entries

Common errors in CI

On conflict, pop leaves the entry on the stack and prints conflict markers; "The stash entry is kept in case you need it again." Resolve, git add, then git stash drop. "No local changes to save" exits non-zero - guard stash calls in scripts.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →