Home Explore Blog CI



git

8th chunk of `Documentation/git-worktree.adoc`
f3f94d7468b65f92e911cc60e1f39403591655ac9bd82c960000000100000c05
 (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 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

------------

Unless `-z` is used any "unusual" characters in the lock reason such as newlines
are escaped and the entire reason is quoted as explained for the
configuration variable `core.quotePath` (see linkgit:git-config[1]).
For Example:

------------
$ git worktree list --porcelain
...
locked "reason\nwhy is locked"
...
------------

EXAMPLES
--------
You are in the middle of a refactoring session and your boss comes in and
demands that you fix something immediately. You might typically use
linkgit:git-stash[1] to store your changes away temporarily, however, your
working tree is in such a state of disarray (with new, moved, and removed
files, and other bits and pieces strewn around) that you don't want to risk
disturbing any of it. Instead, you create a temporary linked worktree to
make the emergency fix, remove it when done, and then resume your earlier
refactoring session.

------------
$ git worktree add -b emergency-fix ../temp master
$ pushd ../temp
# ... hack hack hack ...
$ git commit -a -m 'emergency fix for boss'
$ popd
$ git worktree remove ../temp
------------

BUGS
----
Multiple checkout in general is still experimental, and the support
for submodules is incomplete. It is NOT recommended to make multiple
checkouts of a superproject.

GIT
---
Part of the linkgit:git[1] suite

Title: Git Worktree List Command Porcelain Format and Examples
Summary
The git worktree list command's porcelain format lists attributes with labels and values, with support for boolean attributes and additional information for locked and prunable worktrees, and includes examples of how to use git worktree for temporary fixes and refactoring sessions