Skip to content
LatchkeyLatchkey home

git stash list: Usage, Options & Common CI Errors

git stash list shows every stash entry on the stack, newest first.

Before popping or dropping blindly, list shows what is parked and how each entry is addressed (stash@{0}, stash@{1}, …). It accepts git log formatting for scriptable output.

What it does

git stash list prints the entries of the stash stack, each labelled stash@{n}, with the branch and message recorded when it was created. Accepts log options for custom formatting.

Common usage

Terminal
git stash list
git stash list --stat
git stash list --format='%gd: %s'
git stash show -p stash@{0}      # full diff of one entry

Options

FlagWhat it does
--statShow a diffstat per entry
--format=<fmt>Custom (git log) output format
-p (via stash show)Show the full diff of an entry
stash@{n}Address the nth entry

Common errors in CI

list never errors on an empty stack - it simply prints nothing and exits 0, so scripts should treat empty output (not a non-zero code) as "no stashes". The newest entry is stash@{0}; off-by-one addressing is the usual bug when popping a specific index.

Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached

Frequently asked questions

git stash list: Usage, Options & Common CI Errors?
Before popping or dropping blindly, list shows what is parked and how each entry is addressed (stash@{0}, stash@{1}, …). It accepts git log formatting for scriptable output.
What it does?
git stash list prints the entries of the stash stack, each labelled stash@{n}, with the branch and message recorded when it was created. Accepts log options for custom formatting.
Common errors in CI?
list never errors on an empty stack - it simply prints nothing and exits 0, so scripts should treat empty output (not a non-zero code) as "no stashes". The newest entry is stash@{0}; off-by-one addressing is the usual bug when popping a specific index.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card