Skip to content

CLI Stash Apply

github-actions[bot] edited this page Aug 16, 2026 · 1 revision

quinjet stash apply

Applies one stash to the working tree and leaves it in the list.

Usage:

quinjet stash apply <REFERENCE> [-C <DIR>] [--json]

Arguments:

Name Type / values Default What it does
<REFERENCE> stash@{N} required The stash to apply. Required: unlike pop, apply has no "newest" shortcut.

Options:

Name Type / values Default What it does
-C, --path <DIR> path . The repository to act on. Global.
--json flag off Prints the result sentence as one JSON object instead of a line of text.
-h, --help flag off Prints this verb's help on stdout and exits 0.

The reference is checked before Git sees it. It has to be stash@{ followed by one or more ASCII digits and a closing }, and nothing else, which is the same shape stash list filters its output to. Anything else fails without running Git:

$ quinjet stash apply 'stash@{HEAD}'
error: refusing to use an invalid stash reference

That is exit 1. The check is about shape, not existence: stash@{9} passes it and then fails in Git's own terms with error: Git command failed: stash@{9} is not a valid reference, also exit 1. A shell will eat the braces, so quote the reference.

What runs is:

git stash apply --index stash@{0}

--index is always passed and cannot be turned off. It means the staged half of the stash goes back into the index rather than arriving as unstaged work, so what was staged when the stash was taken is staged again. It is also the part most likely to fail: when the index cannot be restored, for example because those paths have moved on since, Git fails and the verb exits 1. Git may already have written some of the change to the working tree by then, so a failed apply can leave a dirty tree behind. Re-read quinjet status rather than assuming nothing happened.

Applying does not remove the entry, so the same reference stays valid and the indices do not renumber. That is the difference from pop, and it is what makes apply the right verb for putting one stash onto more than one branch. A conflict during the apply leaves the conflicted files in the working tree for quinjet resolve, and the stash remains.

The branch recorded in the stash is not consulted. A stash taken on one branch applies to any other, because Git is merging trees rather than checking a name.

--json shape, an object with one key, naming the reference that was applied:

{
  "message": "Applied stash@{0}"
}

Examples:

quinjet stash apply 'stash@{0}'
quinjet stash apply "stash@{2}"
quinjet stash apply 'stash@{0}' --json
quinjet stash apply 'stash@{1}' -C ~/code/project
$ quinjet stash apply 'stash@{0}'
Applied stash@{0}

Where to go next

CLI reference

Repository
Changes
Remotes
Branch
Stash
Pull Request
Generated
Graft
Mcp
Project
Remote
Stack
Worktree

Guides

Optimization

Git Internals
Diff
Github
Rendering

Rust practices

Studies
Patterns

Clone this wiki locally