@@ -25,8 +25,8 @@ Manage multiple working trees attached to the same repository.
25
25
A git repository can support multiple working trees, allowing you to check
26
26
out more than one branch at a time. With `git worktree add` a new working
27
27
tree is associated with the repository. This new working tree is called a
28
- "linked working tree" as opposed to the "main working tree" prepared by " git
29
- init" or " git clone" . A repository has one main working tree (if it's not a
28
+ "linked working tree" as opposed to the "main working tree" prepared by ` git
29
+ init` or ` git clone` . A repository has one main working tree (if it's not a
30
30
bare repository) and zero or more linked working trees. When you are done
31
31
with a linked working tree, remove it with `git worktree remove`.
32
32
@@ -48,10 +48,10 @@ add <path> [<commit-ish>]::
48
48
49
49
Create `<path>` and checkout `<commit-ish>` into it. The new working directory
50
50
is linked to the current repository, sharing everything except working
51
- directory specific files such as HEAD, index, etc. `-` may also be
51
+ directory specific files such as ` HEAD`, ` index` , etc. `-` may also be
52
52
specified as `<commit-ish>`; it is synonymous with `@{-1}`.
53
53
+
54
- If <commit-ish> is a branch name (call it `<branch>`) and is not found,
54
+ If ` <commit-ish>` is a branch name (call it `<branch>`) and is not found,
55
55
and neither `-b` nor `-B` nor `--detach` are used, but there does
56
56
exist a tracking branch in exactly one remote (call it `<remote>`)
57
57
with a matching name, treat as equivalent to:
@@ -66,13 +66,13 @@ one for the purposes of disambiguation, even if the `<branch>` isn't
66
66
unique across all remotes. Set it to
67
67
e.g. `checkout.defaultRemote=origin` to always checkout remote
68
68
branches from there if `<branch>` is ambiguous but exists on the
69
- ' origin' remote. See also `checkout.defaultRemote` in
69
+ ` origin` remote. See also `checkout.defaultRemote` in
70
70
linkgit:git-config[1].
71
71
+
72
72
If `<commit-ish>` is omitted and neither `-b` nor `-B` nor `--detach` used,
73
73
then, as a convenience, the new worktree is associated with a branch
74
74
(call it `<branch>`) named after `$(basename <path>)`. If `<branch>`
75
- doesn't exist, a new branch based on HEAD is automatically created as
75
+ doesn't exist, a new branch based on ` HEAD` is automatically created as
76
76
if `-b <branch>` was given. If `<branch>` does exist, it will be
77
77
checked out in the new worktree, if it's not checked out anywhere
78
78
else, otherwise the command will refuse to create the worktree (unless
83
83
List details of each worktree. The main worktree is listed first, followed by
84
84
each of the linked worktrees. The output details include if the worktree is
85
85
bare, the revision currently checked out, and the branch currently checked out
86
- (or ' detached HEAD' if none).
86
+ (or " detached HEAD" if none).
87
87
88
88
lock::
89
89
@@ -100,7 +100,7 @@ or linked working trees containing submodules cannot be moved.
100
100
101
101
prune::
102
102
103
- Prune working tree information in $GIT_DIR/worktrees.
103
+ Prune working tree information in ` $GIT_DIR/worktrees` .
104
104
105
105
remove::
106
106
@@ -128,7 +128,7 @@ OPTIONS
128
128
`move` refuses to move a locked working tree unless `--force` is specified
129
129
twice. If the destination is already assigned to some other working tree but is
130
130
missing (for instance, if `<new-path>` was deleted manually), then `--force`
131
- allows the move to proceed; use --force twice if the destination is locked.
131
+ allows the move to proceed; use ` --force` twice if the destination is locked.
132
132
+
133
133
`remove` refuses to remove an unclean working tree unless `--force` is used.
134
134
To remove a locked working tree, specify `--force` twice.
@@ -137,13 +137,13 @@ To remove a locked working tree, specify `--force` twice.
137
137
-B <new-branch>::
138
138
With `add`, create a new branch named `<new-branch>` starting at
139
139
`<commit-ish>`, and check out `<new-branch>` into the new working tree.
140
- If `<commit-ish>` is omitted, it defaults to HEAD.
140
+ If `<commit-ish>` is omitted, it defaults to ` HEAD` .
141
141
By default, `-b` refuses to create a new branch if it already
142
142
exists. `-B` overrides this safeguard, resetting `<new-branch>` to
143
143
`<commit-ish>`.
144
144
145
145
--detach::
146
- With `add`, detach HEAD in the new working tree. See "DETACHED HEAD"
146
+ With `add`, detach ` HEAD` in the new working tree. See "DETACHED HEAD"
147
147
in linkgit:git-checkout[1].
148
148
149
149
--[no-]checkout::
@@ -154,7 +154,7 @@ To remove a locked working tree, specify `--force` twice.
154
154
155
155
--[no-]guess-remote::
156
156
With `worktree add <path>`, without `<commit-ish>`, instead
157
- of creating a new branch from HEAD, if there exists a tracking
157
+ of creating a new branch from ` HEAD` , if there exists a tracking
158
158
branch in exactly one remote matching the basename of `<path>`,
159
159
base the new branch on the remote-tracking branch, and mark
160
160
the remote-tracking branch as "upstream" from the new branch.
@@ -166,7 +166,7 @@ This can also be set up as the default behaviour by using the
166
166
When creating a new branch, if `<commit-ish>` is a branch,
167
167
mark it as "upstream" from the new branch. This is the
168
168
default if `<commit-ish>` is a remote-tracking branch. See
169
- " --track" in linkgit:git-branch[1] for details.
169
+ ` --track` in linkgit:git-branch[1] for details.
170
170
171
171
--lock::
172
172
Keep the working tree locked after creation. This is the
@@ -185,14 +185,14 @@ This can also be set up as the default behaviour by using the
185
185
186
186
-q::
187
187
--quiet::
188
- With ' add' , suppress feedback messages.
188
+ With ` add` , suppress feedback messages.
189
189
190
190
-v::
191
191
--verbose::
192
192
With `prune`, report all removals.
193
193
194
194
--expire <time>::
195
- With `prune`, only expire unused working trees older than <time>.
195
+ With `prune`, only expire unused working trees older than ` <time>` .
196
196
197
197
--reason <string>::
198
198
With `lock`, an explanation why the working tree is locked.
@@ -203,47 +203,47 @@ This can also be set up as the default behaviour by using the
203
203
+
204
204
If the last path components in the working tree's path is unique among
205
205
working trees, it can be used to identify worktrees. For example if
206
- you only have two working trees, at " /abc/def/ghi" and " /abc/def/ggg" ,
207
- then " ghi" or " def/ghi" is enough to point to the former working tree.
206
+ you only have two working trees, at ` /abc/def/ghi` and ` /abc/def/ggg` ,
207
+ then ` ghi` or ` def/ghi` is enough to point to the former working tree.
208
208
209
209
REFS
210
210
----
211
211
In multiple working trees, some refs may be shared between all working
212
- trees, some refs are local. One example is HEAD is different for all
212
+ trees, some refs are local. One example is ` HEAD` is different for all
213
213
working trees. This section is about the sharing rules and how to access
214
214
refs of one working tree from another.
215
215
216
216
In general, all pseudo refs are per working tree and all refs starting
217
- with " refs/" are shared. Pseudo refs are ones like HEAD which are
218
- directly under GIT_DIR instead of inside GIT_DIR/refs. There is one
219
- exception to this: refs inside refs/bisect and refs/worktree is not
217
+ with ` refs/` are shared. Pseudo refs are ones like ` HEAD` which are
218
+ directly under `$ GIT_DIR` instead of inside `$ GIT_DIR/refs` . There is one
219
+ exception to this: refs inside ` refs/bisect` and ` refs/worktree` is not
220
220
shared.
221
221
222
222
Refs that are per working tree can still be accessed from another
223
- working tree via two special paths, main-worktree and worktrees. The
223
+ working tree via two special paths, ` main-worktree` and ` worktrees` . The
224
224
former gives access to per-worktree refs of the main working tree,
225
225
while the latter to all linked working trees.
226
226
227
- For example, main-worktree/HEAD or main-worktree/refs/bisect/good
228
- resolve to the same value as the main working tree's HEAD and
229
- refs/bisect/good respectively. Similarly, worktrees/foo/HEAD or
230
- worktrees/bar/refs/bisect/bad are the same as
231
- GIT_COMMON_DIR/worktrees/foo/HEAD and
232
- GIT_COMMON_DIR/worktrees/bar/refs/bisect/bad.
227
+ For example, ` main-worktree/HEAD` or ` main-worktree/refs/bisect/good`
228
+ resolve to the same value as the main working tree's ` HEAD` and
229
+ ` refs/bisect/good` respectively. Similarly, ` worktrees/foo/HEAD` or
230
+ ` worktrees/bar/refs/bisect/bad` are the same as
231
+ `$ GIT_COMMON_DIR/worktrees/foo/HEAD` and
232
+ `$ GIT_COMMON_DIR/worktrees/bar/refs/bisect/bad` .
233
233
234
- To access refs, it's best not to look inside GIT_DIR directly. Instead
234
+ To access refs, it's best not to look inside `$ GIT_DIR` directly. Instead
235
235
use commands such as linkgit:git-rev-parse[1] or linkgit:git-update-ref[1]
236
236
which will handle refs correctly.
237
237
238
238
CONFIGURATION FILE
239
239
------------------
240
- By default, the repository " config" file is shared across all working
240
+ By default, the repository ` config` file is shared across all working
241
241
trees. If the config variables `core.bare` or `core.worktree` are
242
242
already present in the config file, they will be applied to the main
243
243
working trees only.
244
244
245
245
In order to have configuration specific to working trees, you can turn
246
- on " worktreeConfig" extension, e.g.:
246
+ on ` worktreeConfig` extension, e.g.:
247
247
248
248
------------
249
249
$ git config extensions.worktreeConfig true
@@ -255,7 +255,7 @@ configuration in this file with `git config --worktree`. Older Git
255
255
versions will refuse to access repositories with this extension.
256
256
257
257
Note that in this file, the exception for `core.bare` and `core.worktree`
258
- is gone. If you have them in $GIT_DIR/config before, you must move
258
+ is gone. If you have them in ` $GIT_DIR/config` before, you must move
259
259
them to the `config.worktree` of the main working tree. You may also
260
260
take this opportunity to review and move other configuration that you
261
261
do not want to share to all working trees:
@@ -268,59 +268,59 @@ do not want to share to all working trees:
268
268
DETAILS
269
269
-------
270
270
Each linked working tree has a private sub-directory in the repository's
271
- $GIT_DIR/worktrees directory. The private sub-directory's name is usually
271
+ ` $GIT_DIR/worktrees` directory. The private sub-directory's name is usually
272
272
the base name of the linked working tree's path, possibly appended with a
273
273
number to make it unique. For example, when `$GIT_DIR=/path/main/.git` the
274
274
command `git worktree add /path/other/test-next next` creates the linked
275
275
working tree in `/path/other/test-next` and also creates a
276
276
`$GIT_DIR/worktrees/test-next` directory (or `$GIT_DIR/worktrees/test-next1`
277
277
if `test-next` is already taken).
278
278
279
- Within a linked working tree, $GIT_DIR is set to point to this private
279
+ Within a linked working tree, ` $GIT_DIR` is set to point to this private
280
280
directory (e.g. `/path/main/.git/worktrees/test-next` in the example) and
281
- $GIT_COMMON_DIR is set to point back to the main working tree's $GIT_DIR
281
+ ` $GIT_COMMON_DIR` is set to point back to the main working tree's ` $GIT_DIR`
282
282
(e.g. `/path/main/.git`). These settings are made in a `.git` file located at
283
283
the top directory of the linked working tree.
284
284
285
285
Path resolution via `git rev-parse --git-path` uses either
286
- $GIT_DIR or $GIT_COMMON_DIR depending on the path. For example, in the
286
+ ` $GIT_DIR` or ` $GIT_COMMON_DIR` depending on the path. For example, in the
287
287
linked working tree `git rev-parse --git-path HEAD` returns
288
288
`/path/main/.git/worktrees/test-next/HEAD` (not
289
289
`/path/other/test-next/.git/HEAD` or `/path/main/.git/HEAD`) while `git
290
290
rev-parse --git-path refs/heads/master` uses
291
- $GIT_COMMON_DIR and returns `/path/main/.git/refs/heads/master`,
292
- since refs are shared across all working trees, except refs/bisect and
293
- refs/worktree.
291
+ ` $GIT_COMMON_DIR` and returns `/path/main/.git/refs/heads/master`,
292
+ since refs are shared across all working trees, except ` refs/bisect` and
293
+ ` refs/worktree` .
294
294
295
295
See linkgit:gitrepository-layout[5] for more information. The rule of
296
296
thumb is do not make any assumption about whether a path belongs to
297
- $GIT_DIR or $GIT_COMMON_DIR when you need to directly access something
298
- inside $GIT_DIR. Use `git rev-parse --git-path` to get the final path.
297
+ ` $GIT_DIR` or ` $GIT_COMMON_DIR` when you need to directly access something
298
+ inside ` $GIT_DIR` . Use `git rev-parse --git-path` to get the final path.
299
299
300
- If you manually move a linked working tree, you need to update the ' gitdir' file
300
+ If you manually move a linked working tree, you need to update the ` gitdir` file
301
301
in the entry's directory. For example, if a linked working tree is moved
302
302
to `/newpath/test-next` and its `.git` file points to
303
303
`/path/main/.git/worktrees/test-next`, then update
304
304
`/path/main/.git/worktrees/test-next/gitdir` to reference `/newpath/test-next`
305
305
instead.
306
306
307
- To prevent a $GIT_DIR/worktrees entry from being pruned (which
307
+ To prevent a ` $GIT_DIR/worktrees` entry from being pruned (which
308
308
can be useful in some situations, such as when the
309
309
entry's working tree is stored on a portable device), use the
310
310
`git worktree lock` command, which adds a file named
311
- ' locked' to the entry's directory. The file contains the reason in
311
+ ` locked` to the entry's directory. The file contains the reason in
312
312
plain text. For example, if a linked working tree's `.git` file points
313
313
to `/path/main/.git/worktrees/test-next` then a file named
314
314
`/path/main/.git/worktrees/test-next/locked` will prevent the
315
315
`test-next` entry from being pruned. See
316
316
linkgit:gitrepository-layout[5] for details.
317
317
318
- When extensions.worktreeConfig is enabled, the config file
318
+ When ` extensions.worktreeConfig` is enabled, the config file
319
319
`.git/worktrees/<id>/config.worktree` is read after `.git/config` is.
320
320
321
321
LIST OUTPUT FORMAT
322
322
------------------
323
- The worktree list command has two output formats. The default format shows the
323
+ The ` worktree list` command has two output formats. The default format shows the
324
324
details on a single line with columns. For example:
325
325
326
326
------------
@@ -333,8 +333,8 @@ $ git worktree list
333
333
Porcelain Format
334
334
~~~~~~~~~~~~~~~~
335
335
The porcelain format has a line per attribute. Attributes are listed with a
336
- label and value separated by a single space. Boolean attributes (like ' bare'
337
- and ' detached' ) are listed as a label only, and are only present if and only
336
+ label and value separated by a single space. Boolean attributes (like ` bare`
337
+ and ` detached` ) are listed as a label only, and are only present if and only
338
338
if the value is true. The first attribute of a worktree is always `worktree`,
339
339
an empty line indicates the end of the record. For example:
340
340
0 commit comments