Skip to content
Everyday Git

Stashes

Create, apply, drop, branch and clear, and why a conflicted stash apply has no generic resume.

Create

A stash is planned with the exact scope you chose: a message, whether untracked files come along, and whether the index is kept. The plan counts the changed files it is about to set aside and states the consequence. Your tracked modifications are reverted from the worktree and held in the stash. It is safe, and it refuses when there is nothing to stash.

planned command
git stash push --keep-index -u -m "before the upgrade"
Each flag corresponds to a checkbox you ticked; nothing is added on your behalf.

Stash indices are positional, so the plan pins the object

stash@{0} is a position, not an identity. Create or drop another stash and it means something else. Every apply, drop and branch operation therefore carries the object id of the entry you reviewed, and the plan checks that stash@{n} still resolves to exactly that object before it will run. If the list shifted between review and confirmation, the precondition fails instead of operating on a different stash.

Apply, pop, branch

Apply and pop are the same operation with one flag between them, classified caution because the files may have moved since the stash was made and a conflict is possible. Branching from a stash creates the branch at the stash’s base, applies the entry there, and drops it only if Git applied it successfully: the plan checks that no branch of that name exists first.

Stash operations, their risk classification and what is captured before they run
OperationRiskCaptured first
CreatesafeNothing
Apply / popcautionLight checkpoint: refs, HEAD, index, patches
Branch from a stashcautionLight checkpoint: refs, HEAD, index, patches
DropdestructiveStandard capsule, untracked files included
CleardestructiveNothing: see below

Drop, and clear

Dropping one entry takes a standard capsule first, and the plan is honest about what recovery looks like afterwards: the changes remain findable through the stash reflog until it expires.

Clear takes no capsule, and says so

Clearing removes the stash ref and its reflog entries: that is the point of the command, and a checkpoint would be pretending otherwise. The plan states that no rollback is available and that while Git may retain the cleared objects for a while, the app cannot promise that recovery. If you are not certain, drop entries individually instead.

A conflicted apply has no generic resume

When an apply conflicts, Git leaves you with an unmerged index and no sequencer marker. There is no --continue for a stash apply, and GitAegis does not manufacture one. Continue is only offered for a merge, rebase, cherry-pick, revert or patch application, and an unresolved apply is none of those.

What you get instead is accurate: resolve the conflicts in the resolver and stage them, or abort. Abort for this case restores HEAD and the index with git reset --merge, removes the unmerged entries and the conflict-marker worktree state, and the plan closes with the one fact that matters, the source stash is still there. Applying it again after you have dealt with whatever collided is a normal next step.

30-day trial · No card required

A recovery capsule before every risky Git operation.

You see the exact commands before they run, and the operation is refused if the capsule cannot be written.

Requires Git 2.38.0 or newer, already installed.

Every risky operation, in this order

  1. Previewthe exact commands, shown before anything runs
  2. Capsulerefs, index, staged and working changes, untracked files, operation state: written to disk first
  3. Executethe commands as shown, or not at all
  4. Journalplan, commands, capsule id, outcome
No capsule, no operation. Restore plans, previews, and takes its own capsule.