Home Explore Blog CI



git

7th chunk of `Documentation/git-worktree.adoc`
7bdcdb8ae9da812042c9e383e451d5c2a3829dea3fdd04e00000000100000820
 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 worktree, according to its state.
These annotations are:

 * `locked`, if the worktree is locked.
 * `prunable`, if the worktree 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: worktree 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
worktree itself.

Porcelain Format
~~~~~~~~~~~~~~~~
The porcelain format has a line per attribute.  If `-z` is given then the lines
are terminated with NUL rather than a newline.  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 worktree is always `worktree`, an empty line indicates the
end of the

Title: Git Worktree List Command Output Formats
Summary
The git worktree list command has two output formats: a default format that displays details on a single line with columns, and a porcelain format that lists attributes with labels and values, with optional verbose mode and NUL-terminated lines, providing annotations for worktree states such as locked and prunable