'\" t
.\" Title: git-worktree
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.79.1
.\" Date: 09/28/2018
.\" Manual: Git Manual
.\" Source: Git 2.11.0
.\" Language: English
.\"
.TH "GIT\-WORKTREE" "1" "09/28/2018" "Git 2\&.11\&.0" "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] [\-b ] []
\fIgit worktree list\fR [\-\-porcelain]
\fIgit worktree lock\fR [\-\-reason ]
\fIgit worktree prune\fR [\-n] [\-v] [\-\-expire ]
\fIgit worktree unlock\fR
.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\&. This new working tree is called a "linked working tree" as opposed to the "main working tree" prepared by "git init" or "git clone"\&. A repository has one main working tree (if it\(cqs not a bare repository) and zero or more linked working trees\&.
.sp
When you are done with a linked working tree you can simply delete it\&. The working tree\(cqs administrative files 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 working tree to clean up any stale administrative files\&.
.sp
If you move a linked working tree, you need to manually update the administrative files so that they do not get pruned automatically\&. See section "DETAILS" for more information\&.
.sp
If a linked working tree 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 working tree is locked\&.
.SH "COMMANDS"
.PP
add []
.RS 4
Create
\fB\fR
and checkout
\fB\fR
into it\&. The new working directory is linked to the current repository, sharing everything except working directory specific files such as HEAD, index, etc\&.
\fB\-\fR
may also be specified as
\fB\fR; it is synonymous with
\fB@{\-1}\fR\&.
.sp
If
\fB\fR
is omitted and neither
\fB\-b\fR
nor
\fB\-B\fR
nor
\fB\-\-detached\fR
used, then, as a convenience, a new branch based at HEAD is created automatically, as if
\fB\-b $(basename )\fR
was specified\&.
.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 if the worktree is bare, the revision currently checked out, and the branch currently checked out (or
\fIdetached HEAD\fR
if none)\&.
.RE
.PP
lock
.RS 4
If a working tree 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
prune
.RS 4
Prune working tree information in $GIT_DIR/worktrees\&.
.RE
.PP
unlock
.RS 4
Unlock a working tree, 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 working tree when
\fB\fR
is already checked out by another working tree\&. This option overrides that safeguard\&.
.RE
.PP
\-b , \-B
.RS 4
With
\fBadd\fR, create a new branch named
\fB\fR
starting at
\fB\fR, and check out
\fB\fR
into the new working tree\&. If
\fB\fR
is omitted, it defaults to HEAD\&. By default,
\fB\-b\fR
refuses to create a new branch if it already exists\&.
\fB\-B\fR
overrides this safeguard, resetting
\fB\fR
to
\fB\fR\&.
.RE
.PP
\-\-detach
.RS 4
With
\fBadd\fR, detach HEAD in the new working tree\&. See "DETACHED HEAD" in
\fBgit-checkout\fR(1)\&.
.RE
.PP
\-\-[no\-]checkout
.RS 4
By default,
\fBadd\fR
checks out
\fB\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
\-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
\-v, \-\-verbose
.RS 4
With
\fBprune\fR, report all removals\&.
.RE
.PP
\-\-expire