bf6a1e229c08692bdeaee41ce3cb133ec6663779
   1git-worktree(1)
   2===============
   3
   4NAME
   5----
   6git-worktree - Manage multiple worktrees
   7
   8
   9SYNOPSIS
  10--------
  11[verse]
  12'git worktree prune' [-n] [-v] [--expire <expire>]
  13
  14DESCRIPTION
  15-----------
  16
  17Manage multiple worktrees attached to the same repository. These are
  18created by the command `git checkout --to`.
  19
  20A git repository can support multiple working trees, allowing you to check
  21out more than one branch at a time.  With `git checkout --to` a new working
  22tree is associated with the repository.  This new working tree is called a
  23"linked working tree" as opposed to the "main working tree" prepared by "git
  24init" or "git clone".  A repository has one main working tree (if it's not a
  25bare repository) and zero or more linked working trees.
  26
  27Each linked working tree has a private sub-directory in the repository's
  28$GIT_DIR/worktrees directory.  The private sub-directory's name is usually
  29the base name of the linked working tree's path, possibly appended with a
  30number to make it unique.  For example, when `$GIT_DIR=/path/main/.git` the
  31command `git checkout --to /path/other/test-next next` creates the linked
  32working tree in `/path/other/test-next` and also creates a
  33`$GIT_DIR/worktrees/test-next` directory (or `$GIT_DIR/worktrees/test-next1`
  34if `test-next` is already taken).
  35
  36Within a linked working tree, $GIT_DIR is set to point to this private
  37directory (e.g. `/path/main/.git/worktrees/test-next` in the example) and
  38$GIT_COMMON_DIR is set to point back to the main working tree's $GIT_DIR
  39(e.g. `/path/main/.git`). These settings are made in a `.git` file located at
  40the top directory of the linked working tree.
  41
  42Path resolution via `git rev-parse --git-path` uses either
  43$GIT_DIR or $GIT_COMMON_DIR depending on the path. For example, in the
  44linked working tree `git rev-parse --git-path HEAD` returns
  45`/path/main/.git/worktrees/test-next/HEAD` (not
  46`/path/other/test-next/.git/HEAD` or `/path/main/.git/HEAD`) while `git
  47rev-parse --git-path refs/heads/master` uses
  48$GIT_COMMON_DIR and returns `/path/main/.git/refs/heads/master`,
  49since refs are shared across all working trees.
  50
  51See linkgit:gitrepository-layout[5] for more information. The rule of
  52thumb is do not make any assumption about whether a path belongs to
  53$GIT_DIR or $GIT_COMMON_DIR when you need to directly access something
  54inside $GIT_DIR. Use `git rev-parse --git-path` to get the final path.
  55
  56When you are done with a linked working tree you can simply delete it.
  57The working tree's entry in the repository's $GIT_DIR/worktrees
  58directory will eventually be removed automatically (see
  59`gc.pruneworktreesexpire` in linkgit::git-config[1]), or you can run
  60`git worktree prune` in the main or any linked working tree to
  61clean up any stale entries in $GIT_DIR/worktrees.
  62
  63If you move a linked working directory to another file system, or
  64within a file system that does not support hard links, you need to run
  65at least one git command inside the linked working directory
  66(e.g. `git status`) in order to update its entry in $GIT_DIR/worktrees
  67so that it does not get automatically removed.
  68
  69To prevent a $GIT_DIR/worktrees entry from from being pruned (which
  70can be useful in some situations, such as when the
  71entry's working tree is stored on a portable device), add a file named
  72'locked' to the entry's directory. The file contains the reason in
  73plain text. For example, if a linked working tree's `.git` file points
  74to `/path/main/.git/worktrees/test-next` then a file named
  75`/path/main/.git/worktrees/test-next/locked` will prevent the
  76`test-next` entry from being pruned.  See
  77linkgit:gitrepository-layout[5] for details.
  78
  79COMMANDS
  80--------
  81prune::
  82
  83Prune working tree information in $GIT_DIR/worktrees.
  84
  85OPTIONS
  86-------
  87
  88-n::
  89--dry-run::
  90        With `prune`, do not remove anything; just report what it would
  91        remove.
  92
  93-v::
  94--verbose::
  95        With `prune`, report all removals.
  96
  97--expire <time>::
  98        With `prune`, only expire unused worktrees older than <time>.
  99
 100BUGS
 101----
 102Multiple checkout support for submodules is incomplete. It is NOT
 103recommended to make multiple checkouts of a superproject.
 104
 105git-worktree could provide more automation for tasks currently
 106performed manually or via other commands, such as:
 107
 108- `add` to create a new linked worktree
 109- `remove` to remove a linked worktree and its administrative files (and
 110  warn if the worktree is dirty)
 111- `mv` to move or rename a worktree and update its administrative files
 112- `list` to list linked worktrees
 113- `lock` to prevent automatic pruning of administrative files (for instance,
 114  for a worktree on a portable device)
 115
 116SEE ALSO
 117--------
 118
 119linkgit:git-checkout[1]
 120
 121GIT
 122---
 123Part of the linkgit:git[1] suite