blob: 74f1a3849d29d0a62e267a886263984e763f618c [file] [log] [blame]
'\" t
.\" Title: git-worktree
.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" Date: 03/07/2022
.\" Manual: Git Manual
.\" Source: Git 2.35.1.415.gc2162907e9
.\" Language: English
.\"
.TH "GIT\-WORKTREE" "1" "03/07/2022" "Git 2\&.35\&.1\&.415\&.gc21629" "Git Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
git-worktree \- Manage multiple working trees
.SH "SYNOPSIS"
.sp
.nf
\fIgit worktree add\fR [\-f] [\-\-detach] [\-\-checkout] [\-\-lock [\-\-reason <string>]] [\-b <new\-branch>] <path> [<commit\-ish>]
\fIgit worktree list\fR [\-v | \-\-porcelain]
\fIgit worktree lock\fR [\-\-reason <string>] <worktree>
\fIgit worktree move\fR <worktree> <new\-path>
\fIgit worktree prune\fR [\-n] [\-v] [\-\-expire <expire>]
\fIgit worktree remove\fR [\-f] <worktree>
\fIgit worktree repair\fR [<path>\&...]
\fIgit worktree unlock\fR <worktree>
.fi
.sp
.SH "DESCRIPTION"
.sp
Manage multiple working trees attached to the same repository\&.
.sp
A git repository can support multiple working trees, allowing you to check out more than one branch at a time\&. With \fBgit worktree add\fR a new working tree is associated with the repository, along with additional metadata that differentiates that working tree from others in the same repository\&. The working tree, along with this metadata, is called a "worktree"\&.
.sp
This new worktree is called a "linked worktree" as opposed to the "main worktree" prepared by \fBgit-init\fR(1) or \fBgit-clone\fR(1)\&. A repository has one main worktree (if it\(cqs not a bare repository) and zero or more linked worktrees\&. When you are done with a linked worktree, remove it with \fBgit worktree remove\fR\&.
.sp
In its simplest form, \fBgit worktree add <path>\fR automatically creates a new branch whose name is the final component of \fB<path>\fR, which is convenient if you plan to work on a new topic\&. For instance, \fBgit worktree add \&.\&./hotfix\fR creates new branch \fBhotfix\fR and checks it out at path \fB\&.\&./hotfix\fR\&. To instead work on an existing branch in a new worktree, use \fBgit worktree add <path> <branch>\fR\&. On the other hand, if you just plan to make some experimental changes or do testing without disturbing existing development, it is often convenient to create a \fIthrowaway\fR worktree not associated with any branch\&. For instance, \fBgit worktree add \-d <path>\fR creates a new worktree with a detached \fBHEAD\fR at the same commit as the current branch\&.
.sp
If a working tree is deleted without using \fBgit worktree remove\fR, then its associated administrative files, which reside in the repository (see "DETAILS" below), will eventually be removed automatically (see \fBgc\&.worktreePruneExpire\fR in \fBgit-config\fR(1)), or you can run \fBgit worktree prune\fR in the main or any linked worktree to clean up any stale administrative files\&.
.sp
If the working tree for a linked worktree is stored on a portable device or network share which is not always mounted, you can prevent its administrative files from being pruned by issuing the \fBgit worktree lock\fR command, optionally specifying \fB\-\-reason\fR to explain why the worktree is locked\&.
.SH "COMMANDS"
.PP
add <path> [<commit\-ish>]
.RS 4
Create a worktree at
\fB<path>\fR
and checkout
\fB<commit\-ish>\fR
into it\&. The new worktree is linked to the current repository, sharing everything except per\-worktree files such as
\fBHEAD\fR,
\fBindex\fR, etc\&. As a convenience,
\fB<commit\-ish>\fR
may be a bare "\fB\-\fR", which is synonymous with
\fB@{\-1}\fR\&.
.sp
If
\fB<commit\-ish>\fR
is a branch name (call it
\fB<branch>\fR) and is not found, and neither
\fB\-b\fR
nor
\fB\-B\fR
nor
\fB\-\-detach\fR
are used, but there does exist a tracking branch in exactly one remote (call it
\fB<remote>\fR) with a matching name, treat as equivalent to:
.sp
.if n \{\
.RS 4
.\}
.nf
$ git worktree add \-\-track \-b <branch> <path> <remote>/<branch>
.fi
.if n \{\
.RE
.\}
.sp
If the branch exists in multiple remotes and one of them is named by the
\fBcheckout\&.defaultRemote\fR
configuration variable, we\(cqll use that one for the purposes of disambiguation, even if the
\fB<branch>\fR
isn\(cqt unique across all remotes\&. Set it to e\&.g\&.
\fBcheckout\&.defaultRemote=origin\fR
to always checkout remote branches from there if
\fB<branch>\fR
is ambiguous but exists on the
\fBorigin\fR
remote\&. See also
\fBcheckout\&.defaultRemote\fR
in
\fBgit-config\fR(1)\&.
.sp
If
\fB<commit\-ish>\fR
is omitted and neither
\fB\-b\fR
nor
\fB\-B\fR
nor
\fB\-\-detach\fR
used, then, as a convenience, the new worktree is associated with a branch (call it
\fB<branch>\fR) named after
\fB$(basename <path>)\fR\&. If
\fB<branch>\fR
doesn\(cqt exist, a new branch based on
\fBHEAD\fR
is automatically created as if
\fB\-b <branch>\fR
was given\&. If
\fB<branch>\fR
does exist, it will be checked out in the new worktree, if it\(cqs not checked out anywhere else, otherwise the command will refuse to create the worktree (unless
\fB\-\-force\fR
is used)\&.
.RE
.PP
list
.RS 4
List details of each worktree\&. The main worktree is listed first, followed by each of the linked worktrees\&. The output details include whether the worktree is bare, the revision currently checked out, the branch currently checked out (or "detached HEAD" if none), "locked" if the worktree is locked, "prunable" if the worktree can be pruned by the
\fBprune\fR
command\&.
.RE
.PP
lock
.RS 4
If a worktree is on a portable device or network share which is not always mounted, lock it to prevent its administrative files from being pruned automatically\&. This also prevents it from being moved or deleted\&. Optionally, specify a reason for the lock with
\fB\-\-reason\fR\&.
.RE
.PP
move
.RS 4
Move a worktree to a new location\&. Note that the main worktree or linked worktrees containing submodules cannot be moved with this command\&. (The
\fBgit worktree repair\fR
command, however, can reestablish the connection with linked worktrees if you move the main worktree manually\&.)
.RE
.PP
prune
.RS 4
Prune worktree information in
\fB$GIT_DIR/worktrees\fR\&.
.RE
.PP
remove
.RS 4
Remove a worktree\&. Only clean worktrees (no untracked files and no modification in tracked files) can be removed\&. Unclean worktrees or ones with submodules can be removed with
\fB\-\-force\fR\&. The main worktree cannot be removed\&.
.RE
.PP
repair [<path>\&...]
.RS 4
Repair worktree administrative files, if possible, if they have become corrupted or outdated due to external factors\&.
.sp
For instance, if the main worktree (or bare repository) is moved, linked worktrees will be unable to locate it\&. Running
\fBrepair\fR
in the main worktree will reestablish the connection from linked worktrees back to the main worktree\&.
.sp
Similarly, if the working tree for a linked worktree is moved without using
\fBgit worktree move\fR, the main worktree (or bare repository) will be unable to locate it\&. Running
\fBrepair\fR
within the recently\-moved worktree will reestablish the connection\&. If multiple linked worktrees are moved, running
\fBrepair\fR
from any worktree with each tree\(cqs new
\fB<path>\fR
as an argument, will reestablish the connection to all the specified paths\&.
.sp
If both the main worktree and linked worktrees have been moved manually, then running
\fBrepair\fR
in the main worktree and specifying the new
\fB<path>\fR
of each linked worktree will reestablish all connections in both directions\&.
.RE
.PP
unlock
.RS 4
Unlock a worktree, allowing it to be pruned, moved or deleted\&.
.RE
.SH "OPTIONS"
.PP
\-f, \-\-force
.RS 4
By default,
\fBadd\fR
refuses to create a new worktree when
\fB<commit\-ish>\fR
is a branch name and is already checked out by another worktree, or if
\fB<path>\fR
is already assigned to some worktree but is missing (for instance, if
\fB<path>\fR
was deleted manually)\&. This option overrides these safeguards\&. To add a missing but locked worktree path, specify
\fB\-\-force\fR
twice\&.
.sp
\fBmove\fR
refuses to move a locked worktree unless
\fB\-\-force\fR
is specified twice\&. If the destination is already assigned to some other worktree but is missing (for instance, if
\fB<new\-path>\fR
was deleted manually), then
\fB\-\-force\fR
allows the move to proceed; use
\fB\-\-force\fR
twice if the destination is locked\&.
.sp
\fBremove\fR
refuses to remove an unclean worktree unless
\fB\-\-force\fR
is used\&. To remove a locked worktree, specify
\fB\-\-force\fR
twice\&.
.RE
.PP
\-b <new\-branch>, \-B <new\-branch>
.RS 4
With
\fBadd\fR, create a new branch named
\fB<new\-branch>\fR
starting at
\fB<commit\-ish>\fR, and check out
\fB<new\-branch>\fR
into the new worktree\&. If
\fB<commit\-ish>\fR
is omitted, it defaults to
\fBHEAD\fR\&. By default,
\fB\-b\fR
refuses to create a new branch if it already exists\&.
\fB\-B\fR
overrides this safeguard, resetting
\fB<new\-branch>\fR
to
\fB<commit\-ish>\fR\&.
.RE
.PP
\-d, \-\-detach
.RS 4
With
\fBadd\fR, detach
\fBHEAD\fR
in the new worktree\&. See "DETACHED HEAD" in
\fBgit-checkout\fR(1)\&.
.RE
.PP
\-\-[no\-]checkout
.RS 4
By default,
\fBadd\fR
checks out
\fB<commit\-ish>\fR, however,
\fB\-\-no\-checkout\fR
can be used to suppress checkout in order to make customizations, such as configuring sparse\-checkout\&. See "Sparse checkout" in
\fBgit-read-tree\fR(1)\&.
.RE
.PP
\-\-[no\-]guess\-remote
.RS 4
With
\fBworktree add <path>\fR, without
\fB<commit\-ish>\fR, instead of creating a new branch from
\fBHEAD\fR, if there exists a tracking branch in exactly one remote matching the basename of
\fB<path>\fR, base the new branch on the remote\-tracking branch, and mark the remote\-tracking branch as "upstream" from the new branch\&.
.sp
This can also be set up as the default behaviour by using the
\fBworktree\&.guessRemote\fR
config option\&.
.RE
.PP
\-\-[no\-]track
.RS 4
When creating a new branch, if
\fB<commit\-ish>\fR
is a branch, mark it as "upstream" from the new branch\&. This is the default if
\fB<commit\-ish>\fR
is a remote\-tracking branch\&. See
\fB\-\-track\fR
in
\fBgit-branch\fR(1)
for details\&.
.RE
.PP
\-\-lock
.RS 4
Keep the worktree locked after creation\&. This is the equivalent of
\fBgit worktree lock\fR
after
\fBgit worktree add\fR, but without a race condition\&.
.RE
.PP
\-n, \-\-dry\-run
.RS 4
With
\fBprune\fR, do not remove anything; just report what it would remove\&.
.RE
.PP
\-\-porcelain
.RS 4
With
\fBlist\fR, output in an easy\-to\-parse format for scripts\&. This format will remain stable across Git versions and regardless of user configuration\&. See below for details\&.
.RE
.PP
\-q, \-\-quiet
.RS 4
With
\fBadd\fR, suppress feedback messages\&.
.RE
.PP
\-v, \-\-verbose
.RS 4
With
\fBprune\fR, report all removals\&.
.sp
With
\fBlist\fR, output additional information about worktrees (see below)\&.
.RE
.PP
\-\-expire <time>
.RS 4
With
\fBprune\fR, only expire unused worktrees older than
\fB<time>\fR\&.
.sp
With
\fBlist\fR, annotate missing worktrees as prunable if they are older than
\fB<time>\fR\&.
.RE
.PP
\-\-reason <string>
.RS 4
With
\fBlock\fR
or with
\fBadd \-\-lock\fR, an explanation why the worktree is locked\&.
.RE
.PP
<worktree>
.RS 4
Worktrees can be identified by path, either relative or absolute\&.
.sp
If the last path components in the worktree\(cqs path is unique among worktrees, it can be used to identify a worktree\&. For example if you only have two worktrees, at
\fB/abc/def/ghi\fR
and
\fB/abc/def/ggg\fR, then
\fBghi\fR
or
\fBdef/ghi\fR
is enough to point to the former worktree\&.
.RE
.SH "REFS"
.sp
When using multiple worktrees, some refs are shared between all worktrees, but others are specific to an individual worktree\&. One example is \fBHEAD\fR, which is different for each worktree\&. This section is about the sharing rules and how to access refs of one worktree from another\&.
.sp
In general, all pseudo refs are per\-worktree and all refs starting with \fBrefs/\fR are shared\&. Pseudo refs are ones like \fBHEAD\fR which are directly under \fB$GIT_DIR\fR instead of inside \fB$GIT_DIR/refs\fR\&. There are exceptions, however: refs inside \fBrefs/bisect\fR and \fBrefs/worktree\fR are not shared\&.
.sp
Refs that are per\-worktree can still be accessed from another worktree via two special paths, \fBmain\-worktree\fR and \fBworktrees\fR\&. The former gives access to per\-worktree refs of the main worktree, while the latter to all linked worktrees\&.
.sp
For example, \fBmain\-worktree/HEAD\fR or \fBmain\-worktree/refs/bisect/good\fR resolve to the same value as the main worktree\(cqs \fBHEAD\fR and \fBrefs/bisect/good\fR respectively\&. Similarly, \fBworktrees/foo/HEAD\fR or \fBworktrees/bar/refs/bisect/bad\fR are the same as \fB$GIT_COMMON_DIR/worktrees/foo/HEAD\fR and \fB$GIT_COMMON_DIR/worktrees/bar/refs/bisect/bad\fR\&.
.sp
To access refs, it\(cqs best not to look inside \fB$GIT_DIR\fR directly\&. Instead use commands such as \fBgit-rev-parse\fR(1) or \fBgit-update-ref\fR(1) which will handle refs correctly\&.
.SH "CONFIGURATION FILE"
.sp
By default, the repository \fBconfig\fR file is shared across all worktrees\&. If the config variables \fBcore\&.bare\fR or \fBcore\&.worktree\fR are present in the common config file and \fBextensions\&.worktreeConfig\fR is disabled, then they will be applied to the main worktree only\&.
.sp
In order to have worktree\-specific configuration, you can turn on the \fBworktreeConfig\fR extension, e\&.g\&.:
.sp
.if n \{\
.RS 4
.\}
.nf
$ git config extensions\&.worktreeConfig true
.fi
.if n \{\
.RE
.\}
.sp
.sp
In this mode, specific configuration stays in the path pointed by \fBgit rev\-parse \-\-git\-path config\&.worktree\fR\&. You can add or update configuration in this file with \fBgit config \-\-worktree\fR\&. Older Git versions will refuse to access repositories with this extension\&.
.sp
Note that in this file, the exception for \fBcore\&.bare\fR and \fBcore\&.worktree\fR is gone\&. If they exist in \fB$GIT_DIR/config\fR, you must move them to the \fBconfig\&.worktree\fR of the main worktree\&. You may also take this opportunity to review and move other configuration that you do not want to share to all worktrees:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBcore\&.worktree\fR
should never be shared\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBcore\&.bare\fR
should not be shared if the value is
\fBcore\&.bare=true\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBcore\&.sparseCheckout\fR
should not be shared, unless you are sure you always use sparse checkout for all worktrees\&.
.RE
.sp
See the documentation of \fBextensions\&.worktreeConfig\fR in \fBgit-config\fR(1) for more details\&.
.SH "DETAILS"
.sp
Each linked worktree has a private sub\-directory in the repository\(cqs \fB$GIT_DIR/worktrees\fR directory\&. The private sub\-directory\(cqs name is usually the base name of the linked worktree\(cqs path, possibly appended with a number to make it unique\&. For example, when \fB$GIT_DIR=/path/main/\&.git\fR the command \fBgit worktree add /path/other/test\-next next\fR creates the linked worktree in \fB/path/other/test\-next\fR and also creates a \fB$GIT_DIR/worktrees/test\-next\fR directory (or \fB$GIT_DIR/worktrees/test\-next1\fR if \fBtest\-next\fR is already taken)\&.
.sp
Within a linked worktree, \fB$GIT_DIR\fR is set to point to this private directory (e\&.g\&. \fB/path/main/\&.git/worktrees/test\-next\fR in the example) and \fB$GIT_COMMON_DIR\fR is set to point back to the main worktree\(cqs \fB$GIT_DIR\fR (e\&.g\&. \fB/path/main/\&.git\fR)\&. These settings are made in a \fB\&.git\fR file located at the top directory of the linked worktree\&.
.sp
Path resolution via \fBgit rev\-parse \-\-git\-path\fR uses either \fB$GIT_DIR\fR or \fB$GIT_COMMON_DIR\fR depending on the path\&. For example, in the linked worktree \fBgit rev\-parse \-\-git\-path HEAD\fR returns \fB/path/main/\&.git/worktrees/test\-next/HEAD\fR (not \fB/path/other/test\-next/\&.git/HEAD\fR or \fB/path/main/\&.git/HEAD\fR) while \fBgit rev\-parse \-\-git\-path refs/heads/master\fR uses \fB$GIT_COMMON_DIR\fR and returns \fB/path/main/\&.git/refs/heads/master\fR, since refs are shared across all worktrees, except \fBrefs/bisect\fR and \fBrefs/worktree\fR\&.
.sp
See \fBgitrepository-layout\fR(5) for more information\&. The rule of thumb is do not make any assumption about whether a path belongs to \fB$GIT_DIR\fR or \fB$GIT_COMMON_DIR\fR when you need to directly access something inside \fB$GIT_DIR\fR\&. Use \fBgit rev\-parse \-\-git\-path\fR to get the final path\&.
.sp
If you manually move a linked worktree, you need to update the \fBgitdir\fR file in the entry\(cqs directory\&. For example, if a linked worktree is moved to \fB/newpath/test\-next\fR and its \fB\&.git\fR file points to \fB/path/main/\&.git/worktrees/test\-next\fR, then update \fB/path/main/\&.git/worktrees/test\-next/gitdir\fR to reference \fB/newpath/test\-next\fR instead\&. Better yet, run \fBgit worktree repair\fR to reestablish the connection automatically\&.
.sp
To prevent a \fB$GIT_DIR/worktrees\fR entry from being pruned (which can be useful in some situations, such as when the entry\(cqs worktree is stored on a portable device), use the \fBgit worktree lock\fR command, which adds a file named \fBlocked\fR to the entry\(cqs directory\&. The file contains the reason in plain text\&. For example, if a linked worktree\(cqs \fB\&.git\fR file points to \fB/path/main/\&.git/worktrees/test\-next\fR then a file named \fB/path/main/\&.git/worktrees/test\-next/locked\fR will prevent the \fBtest\-next\fR entry from being pruned\&. See \fBgitrepository-layout\fR(5) for details\&.
.sp
When \fBextensions\&.worktreeConfig\fR is enabled, the config file \fB\&.git/worktrees/<id>/config\&.worktree\fR is read after \fB\&.git/config\fR is\&.
.SH "LIST OUTPUT FORMAT"
.sp
The \fBworktree list\fR command has two output formats\&. The default format shows the details on a single line with columns\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
$ git worktree list
/path/to/bare\-source (bare)
/path/to/linked\-worktree abcd1234 [master]
/path/to/other\-linked\-worktree 1234abc (detached HEAD)
.fi
.if n \{\
.RE
.\}
.sp
.sp
The command also shows annotations for each worktree, according to its state\&. These annotations are:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBlocked\fR, if the worktree is locked\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBprunable\fR, if the worktree can be pruned via
\fBgit worktree prune\fR\&.
.RE
.sp
.if n \{\
.RS 4
.\}
.nf
$ git worktree list
/path/to/linked\-worktree abcd1234 [master]
/path/to/locked\-worktree acbd5678 (brancha) locked
/path/to/prunable\-worktree 5678abc (detached HEAD) prunable
.fi
.if n \{\
.RE
.\}
.sp
.sp
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\&.
.sp
.if n \{\
.RS 4
.\}
.nf
$ 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
.fi
.if n \{\
.RE
.\}
.sp
.sp
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\&.
.SS "Porcelain Format"
.sp
The porcelain format has a line per attribute\&. Attributes are listed with a label and value separated by a single space\&. Boolean attributes (like \fBbare\fR and \fBdetached\fR) are listed as a label only, and are present only if the value is true\&. Some attributes (like \fBlocked\fR) 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 \fBworktree\fR, an empty line indicates the end of the record\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
$ 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
.fi
.if n \{\
.RE
.\}
.sp
.sp
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 \fBcore\&.quotePath\fR (see \fBgit-config\fR(1))\&. For Example:
.sp
.if n \{\
.RS 4
.\}
.nf
$ git worktree list \-\-porcelain
\&.\&.\&.
locked "reason\enwhy is locked"
\&.\&.\&.
.fi
.if n \{\
.RE
.\}
.sp
.SH "EXAMPLES"
.sp
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 \fBgit-stash\fR(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\(cqt 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\&.
.sp
.if n \{\
.RS 4
.\}
.nf
$ git worktree add \-b emergency\-fix \&.\&./temp master
$ pushd \&.\&./temp
# \&.\&.\&. hack hack hack \&.\&.\&.
$ git commit \-a \-m \(aqemergency fix for boss\(aq
$ popd
$ git worktree remove \&.\&./temp
.fi
.if n \{\
.RE
.\}
.sp
.SH "BUGS"
.sp
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\&.
.SH "GIT"
.sp
Part of the \fBgit\fR(1) suite