THE GITHTML FIELD GUIDE
Git stash apply vs pop: restore before removing
Git stash apply restores a saved entry while keeping it in the stash list. Git stash pop tries to restore it and removes it after a successful application; if conflicts prevent success, the entry is retained. Use apply when you want an explicit verification step before deciding whether the saved copy can be removed.
Understand the cleanup difference
Both commands attempt to bring saved changes into the current working state. The important difference is what happens to the saved entry after success. Apply separates restoration from cleanup, which is useful when a task has moved to a different base or contains valuable untracked files. Pop combines those actions for convenience when the situation is well understood.
Neither command guarantees that the restored work is correct on the current branch. A patch can apply cleanly while referring to code that has changed semantically. Also, restoring working edits does not necessarily recreate the previous staged-versus-unstaged arrangement unless the relevant index option is used and can be applied. Decide whether that distinction matters for your task.
Inspect the entry and destination first
Check status before restoration so existing edits are not confused with the incoming stash. Read the stash list and inspect the chosen entry rather than always assuming the newest is correct. Quote the stash expression to avoid shell interpretation. The example intentionally keeps the saved entry available after application.
- Compare restored paths with the stash’s contents, including new files. A partial restoration or conflict requires investigation before cleanup.
- If conflicts occur, inspect the actual operation state and resolve the affected files carefully. Do not run pop repeatedly in an attempt to finish the same application.
git status --short --branch
git stash list
git stash show --include-untracked --stat 'stash@{0}'
git stash apply 'stash@{0}'
git status --shortRemove a saved entry only after evidence
Once the working copy contains the expected changes, run the relevant checks and preserve the result in the intended commit or another verified backup. Only then consider dropping that exact stash. Because numeric stash positions can change, list entries again before deletion. A message and patch summary together are stronger identifiers than a remembered number alone.
For example, after applying a week-old parser experiment, compare it with the current parser interface before committing. The saved patch might compile but restore an obsolete assumption. Retaining the entry during that review provides an additional recovery point, not a substitute for validation. Avoid stash clear for normal task cleanup because it removes unrelated saved work. Choosing apply first is especially helpful when several interrupted tasks coexist and you need a visible, deliberate boundary between recovering work and discarding its temporary copy.
Keep the stash message descriptive enough to distinguish its purpose from other interrupted changes; dates alone rarely explain what the saved work was meant to accomplish.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.