git worktree add

Create <path> and checkout <commit-ish> into it

Options

NameDescription
-f, --forceBy 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
-d, --detachWith add, detach HEAD in the new working tree. See "DETACHED HEAD" in git-checkout[1]
--checkoutBy 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]
--lockKeep the working tree locked after creation. This is the equivalent of git worktree lock after git worktree add, but without a race condition
-b, -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>