Git Worktrees

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9

Syntax

  • git worktree add [-f] [--detach] [--checkout] [-b <new-branch>] <path> [<branch>]
  • git worktree prune [-n] [-v] [--expire <expire>]
  • git worktree list [--porcelain]

Parameters

ParameterDetails
-f --forceBy default, add refuses to create a new working tree when <branch> is already checked out by another working tree. This option overrides that safeguard.
-b <new-branch> -B <new-branch>With add, create a new branch named <new-branch> starting at <branch>, and check out <new-branch> into the new working tree. If <branch> 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 <branch>.
--detachWith add, detach HEAD in the new working tree.
--[no-] checkoutBy default, add checks out <branch>, however, --no-checkout can be used to suppress checkout in order to make customizations, such as configuring sparse-checkout.
-n --dry-runWith prune, do not remove anything; just report what it would remove.
--porcelainWith list, output in an easy-to-parse format for scripts. This format will remain stable across Git versions and regardless of user configuration.
-v --verboseWith prune, report all removals.
--expire <time>With prune, only expire unused working trees older than <time>.

Remarks

See the official documentation for more information: https://git-scm.com/docs/git-worktree.



Got any Git Question?