-f, --force
By default, add
refuses to create a new working tree when
<commit-ish>
is a branch name and is already checked out by
another working tree, or if <path>
is already assigned to
some working tree but is missing (for instance, if <path>
was
deleted manually). This option overrides these safeguards. To
add a missing but locked working tree path, specify --force
twice.
move
refuses to move a locked working tree unless --force
is
specified twice. If the destination is already assigned to
some other working tree but is missing (for instance, if
<new-path>
was deleted manually), then --force
allows the
move to proceed; use --force
twice if the destination is
locked.
remove
refuses to remove an unclean working tree unless
--force
is used. To remove a locked working tree, specify
--force
twice.
-b <new-branch>, -B <new-branch>
With add
, create a new branch named <new-branch>
starting at
<commit-ish>
, and check out <new-branch>
into the new working
tree. If <commit-ish>
is omitted, it defaults to HEAD
. By
default, -b
refuses to create a new branch if it already
exists. -B
overrides this safeguard, resetting <new-branch>
to <commit-ish>
.
-d, --detach
With add
, detach HEAD
in the new working tree. See "DETACHED
HEAD" in git-checkout(1).
--[no-]checkout
By default, add
checks out <commit-ish>
, however,
--no-checkout
can be used to suppress checkout in order to
make customizations, such as configuring sparse-checkout. See
"Sparse checkout" in git-read-tree(1).
--[no-]guess-remote
With worktree add <path>
, without <commit-ish>
, instead of
creating a new branch from HEAD
, if there exists a tracking
branch in exactly one remote matching the basename of <path>
,
base the new branch on the remote-tracking branch, and mark
the remote-tracking branch as "upstream" from the new branch.
This can also be set up as the default behaviour by using the
worktree.guessRemote
config option.
--[no-]track
When creating a new branch, if <commit-ish>
is a branch, mark
it as "upstream" from the new branch. This is the default if
<commit-ish>
is a remote-tracking branch. See --track
in
git-branch(1) for details.
--lock
Keep the working tree locked after creation. This is the
equivalent of git worktree lock
after git worktree add
, but
without a race condition.
-n, --dry-run
With prune
, do not remove anything; just report what it would
remove.
--porcelain
With list
, 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.
-q, --quiet
With add
, suppress feedback messages.
-v, --verbose
With prune
, report all removals.
With list
, output additional information about worktrees (see
below).
--expire <time>
With prune
, only expire unused working trees older than
<time>
.
With list
, annotate missing working trees as prunable if they
are older than <time>
.
--reason <string>
With lock
or with add --lock
, an explanation why the working
tree is locked.
<worktree>
Working trees can be identified by path, either relative or
absolute.
If the last path components in the working tree's path is
unique among working trees, it can be used to identify a
working tree. For example if you only have two working trees,
at /abc/def/ghi
and /abc/def/ggg
, then ghi
or def/ghi
is
enough to point to the former working tree.