@@ -8,16 +8,16 @@ git-worktree - Manage multiple working trees
88
99SYNOPSIS
1010--------
11- [verse ]
12- ' git worktree add' [-f] [-- detach] [-- checkout] [-- lock [-- reason <string >]]
13- [-- orphan] [(-b | -B) <new-branch >] <path > [<commit-ish >]
14- ' git worktree list' [-v | -- porcelain [-z]]
15- ' git worktree lock' [-- reason <string >] <worktree >
16- ' git worktree move' <worktree > <new-path >
17- ' git worktree prune' [-n] [-v] [-- expire <expire >]
18- ' git worktree remove' [-f] <worktree >
19- ' git worktree repair' [<path >... ]
20- ' git worktree unlock' <worktree >
11+ [synopsis ]
12+ git worktree add [-f] [-- detach] [-- checkout] [-- lock [-- reason <string >]]
13+ [-- orphan] [(-b | -B) <new-branch >] <path > [<commit-ish >]
14+ git worktree list [-v | -- porcelain [-z]]
15+ git worktree lock [-- reason <string >] <worktree >
16+ git worktree move <worktree > <new-path >
17+ git worktree prune [-n] [-v] [-- expire <expire >]
18+ git worktree remove [-f] <worktree >
19+ git worktree repair [<path >... ]
20+ git worktree unlock <worktree >
2121
2222DESCRIPTION
2323-----------
@@ -37,7 +37,7 @@ zero or more linked worktrees. When you are done with a linked worktree,
3737remove it with `git worktree remove` .
3838
3939In its simplest form, `git worktree add <path>` automatically creates a
40- new branch whose name is the final component of ` <path>` , which is
40+ new branch whose name is the final component of _ <path>_ , which is
4141convenient if you plan to work on a new topic. For instance, `git
4242worktree add ../hotfix` creates new branch ` hotfix` and checks it out at
4343path `../hotfix` . To instead work on an existing branch in a new worktree,
@@ -63,16 +63,16 @@ locked.
6363
6464COMMANDS
6565--------
66- add <path > [<commit-ish >]::
66+ ` add <path> [<commit-ish>]` ::
6767
68- Create a worktree at ` <path>` and checkout ` <commit-ish>` into it. The new worktree
68+ Create a worktree at _ <path>_ and checkout _ <commit-ish>_ into it. The new worktree
6969is linked to the current repository, sharing everything except per-worktree
70- files such as `HEAD` , `index` , etc. As a convenience, ` <commit-ish>` may
70+ files such as `HEAD` , `index` , etc. As a convenience, _ <commit-ish>_ may
7171be a bare "`-` ", which is synonymous with `@{-1}` .
7272+
73- If ` <commit-ish>` is a branch name (call it ` <branch>` ) and is not found,
73+ If _ <commit-ish>_ is a branch name (call it _ <branch>_ ) and is not found,
7474and neither `-b` nor `-B` nor `--detach` are used, but there does
75- exist a tracking branch in exactly one remote (call it ` <remote>` )
75+ exist a tracking branch in exactly one remote (call it _ <remote>_ )
7676with a matching name, treat as equivalent to:
7777+
7878------------
@@ -81,32 +81,32 @@ $ git worktree add --track -b <branch> <path> <remote>/<branch>
8181+
8282 If the branch exists in multiple remotes and one of them is named by
8383the `checkout.defaultRemote` configuration variable, we'll use that
84- one for the purposes of disambiguation, even if the ` <branch>` isn't
84+ one for the purposes of disambiguation, even if the _ <branch>_ isn't
8585unique across all remotes. Set it to
8686e.g. `checkout.defaultRemote=origin` to always checkout remote
87- branches from there if ` <branch>` is ambiguous but exists on the
87+ branches from there if _ <branch>_ is ambiguous but exists on the
8888`origin` remote. See also `checkout.defaultRemote` in
8989linkgit:git-config[1].
9090+
91- If ` <commit-ish>` is omitted and neither `-b` nor `-B` nor `--detach` used,
91+ If _ <commit-ish>_ is omitted and neither `-b` nor `-B` nor `--detach` used,
9292then, as a convenience, the new worktree is associated with a branch (call
93- it ` <branch>` ) named after `$(basename <path>)` . If ` <branch>` doesn't
93+ it _ <branch>_ ) named after `$(basename <path>)` . If _ <branch>_ doesn't
9494exist, a new branch based on `HEAD` is automatically created as if
95- `-b <branch>` was given. If ` <branch>` does exist, it will be checked out
95+ `-b <branch>` was given. If _ <branch>_ does exist, it will be checked out
9696in the new worktree, if it's not checked out anywhere else, otherwise the
9797command will refuse to create the worktree (unless `--force` is used).
9898+
99- If ` <commit-ish>` is omitted, neither `--detach` , or `--orphan` is
99+ If _ <commit-ish>_ is omitted, neither `--detach` , or `--orphan` is
100100used, and there are no valid local branches (or remote branches if
101101`--guess-remote` is specified) then, as a convenience, the new worktree is
102- associated with a new unborn branch named ` <branch>` (after
102+ associated with a new unborn branch named _ <branch>_ (after
103103`$(basename <path>)` if neither `-b` or `-B` is used) as if `--orphan` was
104104passed to the command. In the event the repository has a remote and
105105`--guess-remote` is used, but no remote or local branches exist, then the
106106command fails with a warning reminding the user to fetch from their remote
107107first (or override by using `-f/--force` ).
108108
109- list::
109+ ` list` ::
110110
111111List details of each worktree. The main worktree is listed first,
112112followed by each of the linked worktrees. The output details include
@@ -115,32 +115,32 @@ branch currently checked out (or "detached HEAD" if none), "locked" if
115115the worktree is locked, "prunable" if the worktree can be pruned by the
116116`prune` command.
117117
118- lock::
118+ ` lock` ::
119119
120120If a worktree is on a portable device or network share which is not always
121121mounted, lock it to prevent its administrative files from being pruned
122122automatically. This also prevents it from being moved or deleted.
123123Optionally, specify a reason for the lock with `--reason` .
124124
125- move::
125+ ` move` ::
126126
127127Move a worktree to a new location. Note that the main worktree or linked
128128worktrees containing submodules cannot be moved with this command. (The
129129`git worktree repair` command, however, can reestablish the connection
130130with linked worktrees if you move the main worktree manually.)
131131
132- prune::
132+ ` prune` ::
133133
134134Prune worktree information in `$GIT_DIR/worktrees` .
135135
136- remove::
136+ ` remove` ::
137137
138138Remove a worktree. Only clean worktrees (no untracked files and no
139139modification in tracked files) can be removed. Unclean worktrees or ones
140140with submodules can be removed with `--force` . The main worktree cannot be
141141removed.
142142
143- repair [<path >... ]::
143+ ` repair [<path>...]` ::
144144
145145Repair worktree administrative files, if possible, if they have become
146146corrupted or outdated due to external factors.
@@ -154,133 +154,133 @@ Similarly, if the working tree for a linked worktree is moved without
154154using `git worktree move` , the main worktree (or bare repository) will be
155155unable to locate it. Running `repair` within the recently-moved worktree
156156will reestablish the connection. If multiple linked worktrees are moved,
157- running `repair` from any worktree with each tree's new ` <path>` as an
157+ running `repair` from any worktree with each tree's new _ <path>_ as an
158158argument, will reestablish the connection to all the specified paths.
159159+
160160If both the main worktree and linked worktrees have been moved or copied manually,
161- then running `repair` in the main worktree and specifying the new ` <path>`
161+ then running `repair` in the main worktree and specifying the new _ <path>_
162162of each linked worktree will reestablish all connections in both
163163directions.
164164
165- unlock::
165+ ` unlock` ::
166166
167167Unlock a worktree, allowing it to be pruned, moved or deleted.
168168
169169OPTIONS
170170-------
171171
172- -f ::
173- -- force::
172+ `-f` ::
173+ ` --force` ::
174174 By default, `add` refuses to create a new worktree when
175- ` <commit-ish>` is a branch name and is already checked out by
176- another worktree, or if ` <path>` is already assigned to some
177- worktree but is missing (for instance, if ` <path>` was deleted
175+ _ <commit-ish>_ is a branch name and is already checked out by
176+ another worktree, or if _ <path>_ is already assigned to some
177+ worktree but is missing (for instance, if _ <path>_ was deleted
178178 manually). This option overrides these safeguards. To add a missing but
179179 locked worktree path, specify `--force` twice.
180180+
181181`move` refuses to move a locked worktree unless `--force` is specified
182182twice. If the destination is already assigned to some other worktree but is
183- missing (for instance, if ` <new-path>` was deleted manually), then `--force`
183+ missing (for instance, if _ <new-path>_ was deleted manually), then `--force`
184184allows the move to proceed; use `--force` twice if the destination is locked.
185185+
186186`remove` refuses to remove an unclean worktree unless `--force` is used.
187187To remove a locked worktree, specify `--force` twice.
188188
189- -b <new-branch >::
190- -B <new-branch >::
191- With `add` , create a new branch named ` <new-branch>` starting at
192- ` <commit-ish>` , and check out ` <new-branch>` into the new worktree.
193- If ` <commit-ish>` is omitted, it defaults to `HEAD` .
189+ ` -b <new-branch>` ::
190+ ` -B <new-branch>` ::
191+ With `add` , create a new branch named _ <new-branch>_ starting at
192+ _ <commit-ish>_ , and check out _ <new-branch>_ into the new worktree.
193+ If _ <commit-ish>_ is omitted, it defaults to `HEAD` .
194194 By default, `-b` refuses to create a new branch if it already
195- exists. `-B` overrides this safeguard, resetting ` <new-branch>` to
196- ` <commit-ish>` .
195+ exists. `-B` overrides this safeguard, resetting _ <new-branch>_ to
196+ _ <commit-ish>_ .
197197
198- -d ::
199- -- detach::
198+ `-d` ::
199+ ` --detach` ::
200200 With `add` , detach `HEAD` in the new worktree. See "DETACHED HEAD"
201201 in linkgit:git-checkout[1].
202202
203- -- checkout::
204- -- no-checkout::
205- By default, `add` checks out ` <commit-ish>` , however, `--no-checkout` can
203+ ` --checkout` ::
204+ ` --no-checkout` ::
205+ By default, `add` checks out _ <commit-ish>_ , however, `--no-checkout` can
206206 be used to suppress checkout in order to make customizations,
207207 such as configuring sparse-checkout. See "Sparse checkout"
208208 in linkgit:git-read-tree[1].
209209
210- -- guess-remote::
211- -- no-guess-remote::
212- With `worktree add <path>` , without ` <commit-ish>` , instead
210+ ` --guess-remote` ::
211+ ` --no-guess-remote` ::
212+ With `worktree add <path>` , without _ <commit-ish>_ , instead
213213 of creating a new branch from `HEAD` , if there exists a tracking
214- branch in exactly one remote matching the basename of ` <path>` ,
214+ branch in exactly one remote matching the basename of _ <path>_ ,
215215 base the new branch on the remote-tracking branch, and mark
216216 the remote-tracking branch as "upstream" from the new branch.
217217+
218218This can also be set up as the default behaviour by using the
219219`worktree.guessRemote` config option.
220220
221- -- relative-paths::
222- -- no-relative-paths::
221+ ` --relative-paths` ::
222+ ` --no-relative-paths` ::
223223 Link worktrees using relative paths or absolute paths (default).
224224 Overrides the `worktree.useRelativePaths` config option, see
225225 linkgit:git-config[1].
226226+
227227With `repair` , the linking files will be updated if there's an absolute/relative
228228mismatch, even if the links are correct.
229229
230- -- track::
231- -- no-track::
232- When creating a new branch, if ` <commit-ish>` is a branch,
230+ ` --track` ::
231+ ` --no-track` ::
232+ When creating a new branch, if _ <commit-ish>_ is a branch,
233233 mark it as "upstream" from the new branch. This is the
234- default if ` <commit-ish>` is a remote-tracking branch. See
234+ default if _ <commit-ish>_ is a remote-tracking branch. See
235235 `--track` in linkgit:git-branch[1] for details.
236236
237- -- lock::
237+ ` --lock` ::
238238 Keep the worktree locked after creation. This is the
239239 equivalent of `git worktree lock` after `git worktree add` ,
240240 but without a race condition.
241241
242- -n ::
243- -- dry-run::
242+ `-n` ::
243+ ` --dry-run` ::
244244 With `prune` , do not remove anything; just report what it would
245245 remove.
246246
247- -- orphan::
247+ ` --orphan` ::
248248 With `add` , make the new worktree and index empty, associating
249- the worktree with a new unborn branch named ` <new-branch>` .
249+ the worktree with a new unborn branch named _ <new-branch>_ .
250250
251- -- porcelain::
251+ ` --porcelain` ::
252252 With `list` , output in an easy-to-parse format for scripts.
253253 This format will remain stable across Git versions and regardless of user
254254 configuration. It is recommended to combine this with `-z` .
255255 See below for details.
256256
257- -z ::
258- Terminate each line with a NUL rather than a newline when
257+ `-z` ::
258+ Terminate each line with a _NUL_ rather than a newline when
259259 `--porcelain` is specified with `list` . This makes it possible
260260 to parse the output when a worktree path contains a newline
261261 character.
262262
263- -q ::
264- -- quiet::
263+ `-q` ::
264+ ` --quiet` ::
265265 With `add` , suppress feedback messages.
266266
267- -v ::
268- -- verbose::
267+ `-v` ::
268+ ` --verbose` ::
269269 With `prune` , report all removals.
270270+
271271With `list` , output additional information about worktrees (see below).
272272
273- -- expire <time >::
274- With `prune` , only expire unused worktrees older than ` <time>` .
273+ ` --expire <time>` ::
274+ With `prune` , only expire unused worktrees older than _ <time>_ .
275275+
276276With `list` , annotate missing worktrees as prunable if they are older than
277- ` <time>` .
277+ _ <time>_ .
278278
279- -- reason <string >::
279+ ` --reason <string>` ::
280280 With `lock` or with `add --lock` , an explanation why the worktree
281281 is locked.
282282
283- <worktree >::
283+ _ <worktree>_ ::
284284 Worktrees can be identified by path, either relative or absolute.
285285+
286286If the last path components in the worktree's path is unique among
@@ -522,6 +522,13 @@ $ popd
522522$ git worktree remove ../temp
523523------------
524524
525+ CONFIGURATION
526+ -------------
527+
528+ include::includes/cmd-config-section-all.adoc[]
529+
530+ include::config/worktree.adoc[]
531+
525532BUGS
526533----
527534Multiple checkout in general is still experimental, and the support
0 commit comments