Repository navigation
CLI Stash
quinjet stash is the whole of Git's stash reflog behind seven verbs: read it
with list, add to it with push, take work back out with apply or pop,
throw an entry away with drop, empty it with clear, and read one entry as a
patch with show. It is the group to reach for when a branch switch, a pull or
a review needs the working tree clean for a moment, and for the far more common
case of finding out what is already in there before deciding whether it is safe
to delete.
Nothing in this group touches the network, GitHub or the cache. Every verb is
one or a few git invocations against the worktree root that -C resolves to,
run with LC_ALL=C, GIT_OPTIONAL_LOCKS=0, GIT_TERMINAL_PROMPT=0 and
-c core.quotepath=false, with arguments handed to git as an array rather
than through a shell. A message or a reference containing a space, a quote or a
semicolon is one argument and nothing else.
Reading the list is a single call:
git stash list --format=%gd%x1f%gs%x1f%cr%x1f%h%x1e. Records are separated by
0x1e and fields by 0x1f, so no delimiter can appear inside a message. The
four fields are the reflog selector %gd, the reflog subject %gs, the
committer date relative %cr and the abbreviated hash %h. A record with fewer
than four fields is skipped, and a record whose selector is not literally
stash@{N} with an all-digit N is dropped rather than passed on. That filter
is what makes the rest of the group safe: every reference Quinjet later hands to
Git is checked against the same stash@{N} shape by validate_stash_reference,
and anything else fails with refusing to use an invalid stash reference
before git is executed.
The reflog subject is where the branch and the message come from. Git writes
WIP on <branch>: <commit> <subject> for a stash with no message and
On <branch>: <message> for one with a message, so Quinjet strips whichever of
the two prefixes matches and splits the rest on its first colon and space. What is left of
that split is the branch, what is right of it is the message. A subject with
neither prefix leaves the branch empty, and a stash taken with a detached HEAD
reports the branch Git wrote, which is (no branch).
Writing is deliberately thin. push builds git stash push and appends
--include-untracked or --staged when asked and --message <text> only when
the trimmed message is not empty. apply and pop both run with --index, so
what was staged when the stash was taken is staged again. drop and clear
refuse to act without --yes: without it they print the sentence describing
what they would have done, run no destructive Git command at all, and exit 0.
show is the one verb doing real work of its own. A stash commit's first parent
is the HEAD it was taken from, so the tracked half of the patch is
git diff <ref>^1 <ref>. Untracked files, when --include-untracked was used,
live in a third-parent root commit instead, and older Git cannot path-filter
git stash show, so the untracked half is read separately with
git show <ref>^3 and appended to the same document. Read
quinjet stash show before relying on it: the probe for that third
parent misbehaves on current Git, and the verb only succeeds today for stashes
that actually have an untracked half.
| Command | What it does |
|---|---|
quinjet stash list |
Prints every stash, newest first, with its reference, hash, age, branch and message. |
quinjet stash push |
Stashes the current changes, optionally with a message, including untracked files, or the index alone. |
quinjet stash apply |
Applies one stash and keeps it in the list, restoring the index too. |
quinjet stash pop |
Applies one stash and drops it. With no reference, pops the newest. |
quinjet stash drop |
Deletes one stash. Needs --yes. |
quinjet stash clear |
Deletes every stash. Needs --yes. |
quinjet stash show |
Prints one stash as a patch, tracked changes and untracked additions together. |
quinjet stash listquinjet stash pushquinjet stash applyquinjet stash popquinjet stash dropquinjet stash clearquinjet stash show
| Code | When this group produces it |
|---|---|
| 0 |
list printed, including the empty list. show printed a patch. push, apply, pop, drop --yes and clear --yes succeeded. drop and clear without --yes reported what they would do and changed nothing. --help on the group or any verb. |
| 1 | Git refused: pop with an empty stash list (No stash entries found.), drop stash@{9} where there is no ninth entry (stash@{9} is not a valid reference), push on a branch with no commits (You do not have the initial commit yet), an apply or pop whose index could not be restored, show failing on <ref>^3. Also a reference of valid shape rejected by validate_stash_reference, and -C pointing somewhere that is not a repository. |
| 2 | clap rejected the command line: quinjet stash with no verb, apply, drop or show with no <REFERENCE>, an unknown flag, or push --staged --include-untracked, which reports the argument '--staged' cannot be used with '--include-untracked'. |
| 3 |
show was given a reference that is not in stash list, including a well-formed one such as stash@{9} in a repository with two stashes. The hint always names quinjet stash list as the way to see what exists. |
This group never exits 4. Nothing here can name a thing that exists and cannot be read.
- Stash references are positions, not names.
stash@{0}is always the newest entry, and everypush,popanddroprenumbers everything after it. A reference read in one command and used in the next is a race if anything else is touching the repository: another terminal, an editor's Git integration, or the Quinjet interface open in another window. Readstash listand act in one go, and preferpopwith no reference when you mean "the last thing I stashed". - The
shortIdinstash listis the stash commit itself and is stable across renumbering, but no verb in this group accepts it. Onlystash@{N}is accepted, byapply,pop,dropandshowalike. -
listhas no limit, no filter and no--all. The entire stash reflog is read and printed in Git's own order, newest first, with no sorting of Quinjet's own. Unlike a diff read, it is not bounded by a byte cap. - An empty stash list is not an error.
quinjet stash listprints nothing at all and exits 0;--jsonprints[]. - The branch column comes from the reflog subject rather than from any ref, so it is whatever the branch was called when the stash was taken. Renaming or deleting that branch afterwards does not change it, and applying a stash onto a different branch is allowed: Git only cares about the trees.
- A stash written by something other than
git stash push, for examplegit stash store -m "custom label", has neither theWIP onnor theOnprefix, so its branch parses as the empty string and the row readsstash@{0} 94eaeda 0 seconds ago on : custom label. Thebranchkey in--jsonis""in that case, nevernull. -
pushwith a message that is empty or only whitespace omits--messageentirely rather than passing an empty one, so Git writes its ownWIP on <branch>: <commit> <subject>subject. Messages are trimmed before they are passed, so leading and trailing spaces never reach the reflog. -
pushon a clean working tree is not a failure. Git printsNo local changes to saveand exits 0, so Quinjet printsChanges stashedand exits 0 even though nothing was stashed. Check withstash listafterwards if it matters. -
push --stagedneeds Git 2.35 or newer. On anything older Git rejects the option and the verb exits 1 with Git's own message.--stagedand--include-untrackedare mutually exclusive, and clap rejects the pair before any Git runs. -
pushimplements three variants plus optional pathspecs. There is no--keep-index, no--allfor ignored files, and no--patch. There is also noquinjet stash branch, nocreateand nostore. -
applyandpopalways pass--index. There is no way to ask for the working-tree half alone. When Git cannot reinstate the index it fails and the verb exits 1, and Git may already have written some of the changes to the working tree by then, so a failedpopcan leave both the stash and a dirty tree behind. Re-readquinjet statusrather than assuming. -
applyrequires a reference. Onlypopmakes it optional, and onlypopwith no reference reportsPopped latest stashinstead of naming one. -
dropandclearfollow the same--yesrule asquinjet discardandquinjet branch delete, described in conventions and contracts. Without--yesthey exit 0 having changed nothing, so a missing confirmation is never an error to handle.dropwithout--yesdoes not check that the reference exists either: it prints its sentence for any string at all. -
clearwithout--yesdoes read the list, to count it, and its sentence is never pluralized: one stash producesWould drop 1 stashes. Pass --yes to drop them.clear --yeson an empty list still succeeds and still saysDropped all stashes. - A dropped stash is not gone from the object database immediately, but Quinjet
offers nothing to get it back. Recovery means
git fsck --unreachableandgit stash store, outside Quinjet. -
showlooks its reference up instash listfirst, which is why an unknown reference exits 3 with a hint rather than reaching Git. The shape check that produces exit 1 elsewhere is therefore unreachable fromshow. -
showbuilds the file list withgit stash show --name-status -z --include-untracked <ref> --, and asks for the same listing again as--numstatto fill in the+n -ncounts. The numstat read is best-effort: if it fails the counts render as+? -?rather than failing the verb. -
showthen reads one patch per file, so a stash touching twenty files costs roughly twentygit diffcalls, twentygit rev-parseprobes and up to twentygit showcalls, plus the two index reads. It is not onegit stash show -p. - Because the tracked half is
<ref>^1 <ref>, the patch is the stash's whole change against the commit it was taken from: staged and unstaged work appear together with no way to tell them apart. A--stagedstash is the exception, since its tree only ever held the index. -
showcurrently fails for a stash that has no untracked half. The existence probe isgit rev-parse --verify "<ref>^3^{commit}", and on Git 2.43 the nested braces make Git read the whole thing as a reflog date rather than a parent, so the probe succeeds for every stash. The followinggit show <ref>^3then fails and the verb exits 1 witherror: Git command failed: fatal: bad revision 'stash@{0}^3'. Stashes taken with--include-untrackedare unaffected. Seeshow. - The size caps in conventions and contracts apply to
show: 8 MiB per file patch and 8 MiB or 16,384 paths for the file listing. The untracked half is read with whatever is left of the 8 MiB after the tracked half, and is skipped entirely when the tracked half already hit the cap. Crossing a cap appends[output reached Quinjet's size cap and was truncated]rather than pretending the patch is complete. -
--expandedonshowmeans--unified=1000000instead of--unified=3, on both halves. It is thetkey of the terminal interface, and it does not add files: a file with no change in this stash is still absent. - Nothing in this group is cached, watched or refreshed. There is no
--watchand no--refreshon any stash verb, and--jsonis the global flag described in conventions, soquinjet --json stash listandquinjet stash list --jsonare the same run. - On an unborn branch,
listworks and prints nothing, andpushfails withYou do not have the initial commit yet. On a detached HEAD everything works and the stash records(no branch). - A bare repository has no worktree, so
push,applyandpopfail in Git's own terms.listwill happily print an empty list. - The mutating verbs run through the same command layer the terminal interface
uses, so the sentence on stdout is the same string the interface puts in a
toast. In the Changes view,
Sopens the Stashes modal; inside it Ctrl-N, Ctrl-U and Ctrl-S arepush,push --include-untrackedandpush --staged, Alt-A isapply, Alt-P ispop, Delete isdropbehind a confirmation, Ctrl-Delete isclearbehind a confirmation, and Enter previews the selected stash with exactly whatstash showprints. - Platform differences come from Git, not from Quinjet. The one thing worth knowing is that a stash records file modes, so a tree stashed on a filesystem that keeps the executable bit and applied on one that does not will differ in the mode Git reports.
-
quinjet status,diff,log,showfor reading the working tree a stash came from or landed in -
quinjet stage,unstage,discard,commitfor the other verbs that move the index, including the--yesguarddropandclearshare withdiscard -
quinjet branchfor the switch a stash usually exists to make possible -
Conventions and contracts for
--json, the exit-code table and the size caps this page refers to - All
quinjetcommands
Generated from docs/, edit the docs in the repo, not the wiki.
CLI reference
Pull Request
- View
- Commits
- Files
- Diff
- Conversation
- Checks
- Logs
- Open
- Merge
- Admin Merge
- Auto Merge
- Disable Auto Merge
- Dequeue
- Ready
- Draft
- Review
- Reviews
- Comment
- Edit Last Comment
- Delete Last Comment
- Edit
- Update Branch
- Lock
- Unlock
- Subscribe
- Unsubscribe
- Allow Maintainer Edits
- Disallow Maintainer Edits
- Revert
- Close
- Reopen
Guides
Optimization
Rust practices