The worktree list
command has two output formats. The default
format shows the details on a single line with columns. For
example:
$ git worktree list
/path/to/bare-source (bare)
/path/to/linked-worktree abcd1234 [master]
/path/to/other-linked-worktree 1234abc (detached HEAD)
The command also shows annotations for each working tree,
according to its state. These annotations are:
• locked
, if the working tree is locked.
• prunable
, if the working tree can be pruned via git worktree
prune
.
$ git worktree list
/path/to/linked-worktree abcd1234 [master]
/path/to/locked-worktree acbd5678 (brancha) locked
/path/to/prunable-worktree 5678abc (detached HEAD) prunable
For these annotations, a reason might also be available and this
can be seen using the verbose mode. The annotation is then moved
to the next line indented followed by the additional information.
$ git worktree list --verbose
/path/to/linked-worktree abcd1234 [master]
/path/to/locked-worktree-no-reason abcd5678 (detached HEAD) locked
/path/to/locked-worktree-with-reason 1234abcd (brancha)
locked: working tree path is mounted on a portable device
/path/to/prunable-worktree 5678abc1 (detached HEAD)
prunable: gitdir file points to non-existent location
Note that the annotation is moved to the next line if the
additional information is available, otherwise it stays on the
same line as the working tree itself.
Porcelain Format
The porcelain format has a line per attribute. Attributes are
listed with a label and value separated by a single space.
Boolean attributes (like bare
and detached
) are listed as a label
only, and are present only if the value is true. Some attributes
(like locked
) can be listed as a label only or with a value
depending upon whether a reason is available. The first attribute
of a working tree is always worktree
, an empty line indicates the
end of the record. For example:
$ git worktree list --porcelain
worktree /path/to/bare-source
bare
worktree /path/to/linked-worktree
HEAD abcd1234abcd1234abcd1234abcd1234abcd1234
branch refs/heads/master
worktree /path/to/other-linked-worktree
HEAD 1234abc1234abc1234abc1234abc1234abc1234a
detached
worktree /path/to/linked-worktree-locked-no-reason
HEAD 5678abc5678abc5678abc5678abc5678abc5678c
branch refs/heads/locked-no-reason
locked
worktree /path/to/linked-worktree-locked-with-reason
HEAD 3456def3456def3456def3456def3456def3456b
branch refs/heads/locked-with-reason
locked reason why is locked
worktree /path/to/linked-worktree-prunable
HEAD 1233def1234def1234def1234def1234def1234b
detached
prunable gitdir file points to non-existent location
If the lock reason contains "unusual" characters such as newline,
they are escaped and the entire reason is quoted as explained for
the configuration variable core.quotePath
(see git-config(1)).
For Example:
$ git worktree list --porcelain
...
locked "reason\nwhy is locked"
...