Skip to content
LatchkeyLatchkey home

git worktree list: Usage, Options & Common CI Errors

git worktree list shows all working trees attached to the repository and what each has checked out.

When a job juggles several worktrees, list is how you discover what exists, where, and on which branch - with a stable --porcelain format for scripts.

What it does

git worktree list prints each linked working tree with its path, current HEAD, and checked-out branch, flagging bare, detached, locked, or prunable trees.

Common usage

Terminal
git worktree list
git worktree list --porcelain
git worktree list -v             # show lock/prunable reasons

Options

FlagWhat it does
--porcelainStable, machine-readable output
-v / --verboseShow extra annotations (locked, prunable)
-zNUL-terminate records (with --porcelain)

Common errors in CI

A worktree whose directory was deleted manually still appears as "prunable" until you run git worktree prune; parse --porcelain (not the human format) so a stale entry does not break a script. The main worktree is always listed first.

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 worktree list: Usage, Options & Common CI Errors?
When a job juggles several worktrees, list is how you discover what exists, where, and on which branch - with a stable --porcelain format for scripts.
What it does?
git worktree list prints each linked working tree with its path, current HEAD, and checked-out branch, flagging bare, detached, locked, or prunable trees.
Common errors in CI?
A worktree whose directory was deleted manually still appears as "prunable" until you run git worktree prune; parse --porcelain (not the human format) so a stale entry does not break a script. The main worktree is always listed first.

Related guides

References

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