Skip to content

Commit a3afa4b

Browse files
committed
Merge branch 'es/worktree-doc-cleanups'
Doc cleanup around "worktree". * es/worktree-doc-cleanups: git-worktree.txt: link to man pages when citing other Git commands git-worktree.txt: make start of new sentence more obvious git-worktree.txt: fix minor grammatical issues git-worktree.txt: consistently use term "working tree" git-worktree.txt: employ fixed-width typeface consistently
2 parents e0ad957 + dc9c144 commit a3afa4b

File tree

1 file changed

+62
-61
lines changed

1 file changed

+62
-61
lines changed

Documentation/git-worktree.txt

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ Manage multiple working trees attached to the same repository.
2525
A git repository can support multiple working trees, allowing you to check
2626
out more than one branch at a time. With `git worktree add` a new working
2727
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
29+
linkgit:git-init[1] or linkgit:git-clone[1].
30+
A repository has one main working tree (if it's not a
3031
bare repository) and zero or more linked working trees. When you are done
3132
with a linked working tree, remove it with `git worktree remove`.
3233

@@ -48,10 +49,10 @@ add <path> [<commit-ish>]::
4849

4950
Create `<path>` and checkout `<commit-ish>` into it. The new working directory
5051
is linked to the current repository, sharing everything except working
51-
directory specific files such as HEAD, index, etc. `-` may also be
52-
specified as `<commit-ish>`; it is synonymous with `@{-1}`.
52+
directory specific files such as `HEAD`, `index`, etc. As a convenience,
53+
`<commit-ish>` may be a bare "`-`", which is synonymous with `@{-1}`.
5354
+
54-
If <commit-ish> is a branch name (call it `<branch>`) and is not found,
55+
If `<commit-ish>` is a branch name (call it `<branch>`) and is not found,
5556
and neither `-b` nor `-B` nor `--detach` are used, but there does
5657
exist a tracking branch in exactly one remote (call it `<remote>`)
5758
with a matching name, treat as equivalent to:
@@ -66,24 +67,24 @@ one for the purposes of disambiguation, even if the `<branch>` isn't
6667
unique across all remotes. Set it to
6768
e.g. `checkout.defaultRemote=origin` to always checkout remote
6869
branches from there if `<branch>` is ambiguous but exists on the
69-
'origin' remote. See also `checkout.defaultRemote` in
70+
`origin` remote. See also `checkout.defaultRemote` in
7071
linkgit:git-config[1].
7172
+
7273
If `<commit-ish>` is omitted and neither `-b` nor `-B` nor `--detach` used,
73-
then, as a convenience, the new worktree is associated with a branch
74+
then, as a convenience, the new working tree is associated with a branch
7475
(call it `<branch>`) named after `$(basename <path>)`. If `<branch>`
75-
doesn't exist, a new branch based on HEAD is automatically created as
76+
doesn't exist, a new branch based on `HEAD` is automatically created as
7677
if `-b <branch>` was given. If `<branch>` does exist, it will be
77-
checked out in the new worktree, if it's not checked out anywhere
78-
else, otherwise the command will refuse to create the worktree (unless
78+
checked out in the new working tree, if it's not checked out anywhere
79+
else, otherwise the command will refuse to create the working tree (unless
7980
`--force` is used).
8081

8182
list::
8283

83-
List details of each worktree. The main worktree is listed first, followed by
84-
each of the linked worktrees. The output details include if the worktree is
85-
bare, the revision currently checked out, and the branch currently checked out
86-
(or 'detached HEAD' if none).
84+
List details of each working tree. The main working tree is listed first,
85+
followed by each of the linked working trees. The output details include
86+
whether the working tree is bare, the revision currently checked out, and the
87+
branch currently checked out (or "detached HEAD" if none).
8788

8889
lock::
8990

@@ -100,7 +101,7 @@ or linked working trees containing submodules cannot be moved.
100101

101102
prune::
102103

103-
Prune working tree information in $GIT_DIR/worktrees.
104+
Prune working tree information in `$GIT_DIR/worktrees`.
104105

105106
remove::
106107

@@ -128,7 +129,7 @@ OPTIONS
128129
`move` refuses to move a locked working tree unless `--force` is specified
129130
twice. If the destination is already assigned to some other working tree but is
130131
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.
132+
allows the move to proceed; use `--force` twice if the destination is locked.
132133
+
133134
`remove` refuses to remove an unclean working tree unless `--force` is used.
134135
To remove a locked working tree, specify `--force` twice.
@@ -137,13 +138,13 @@ To remove a locked working tree, specify `--force` twice.
137138
-B <new-branch>::
138139
With `add`, create a new branch named `<new-branch>` starting at
139140
`<commit-ish>`, and check out `<new-branch>` into the new working tree.
140-
If `<commit-ish>` is omitted, it defaults to HEAD.
141+
If `<commit-ish>` is omitted, it defaults to `HEAD`.
141142
By default, `-b` refuses to create a new branch if it already
142143
exists. `-B` overrides this safeguard, resetting `<new-branch>` to
143144
`<commit-ish>`.
144145

145146
--detach::
146-
With `add`, detach HEAD in the new working tree. See "DETACHED HEAD"
147+
With `add`, detach `HEAD` in the new working tree. See "DETACHED HEAD"
147148
in linkgit:git-checkout[1].
148149

149150
--[no-]checkout::
@@ -154,7 +155,7 @@ To remove a locked working tree, specify `--force` twice.
154155

155156
--[no-]guess-remote::
156157
With `worktree add <path>`, without `<commit-ish>`, instead
157-
of creating a new branch from HEAD, if there exists a tracking
158+
of creating a new branch from `HEAD`, if there exists a tracking
158159
branch in exactly one remote matching the basename of `<path>`,
159160
base the new branch on the remote-tracking branch, and mark
160161
the remote-tracking branch as "upstream" from the new branch.
@@ -166,12 +167,12 @@ This can also be set up as the default behaviour by using the
166167
When creating a new branch, if `<commit-ish>` is a branch,
167168
mark it as "upstream" from the new branch. This is the
168169
default if `<commit-ish>` is a remote-tracking branch. See
169-
"--track" in linkgit:git-branch[1] for details.
170+
`--track` in linkgit:git-branch[1] for details.
170171

171172
--lock::
172173
Keep the working tree locked after creation. This is the
173174
equivalent of `git worktree lock` after `git worktree add`,
174-
but without race condition.
175+
but without a race condition.
175176

176177
-n::
177178
--dry-run::
@@ -185,14 +186,14 @@ This can also be set up as the default behaviour by using the
185186

186187
-q::
187188
--quiet::
188-
With 'add', suppress feedback messages.
189+
With `add`, suppress feedback messages.
189190

190191
-v::
191192
--verbose::
192193
With `prune`, report all removals.
193194

194195
--expire <time>::
195-
With `prune`, only expire unused working trees older than <time>.
196+
With `prune`, only expire unused working trees older than `<time>`.
196197

197198
--reason <string>::
198199
With `lock`, an explanation why the working tree is locked.
@@ -202,48 +203,48 @@ This can also be set up as the default behaviour by using the
202203
absolute.
203204
+
204205
If the last path components in the working tree's path is unique among
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+
working trees, it can be used to identify a working tree. For example if
207+
you only have two working trees, at `/abc/def/ghi` and `/abc/def/ggg`,
208+
then `ghi` or `def/ghi` is enough to point to the former working tree.
208209

209210
REFS
210211
----
211212
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
213-
working trees. This section is about the sharing rules and how to access
213+
trees and some refs are local. One example is `HEAD` which is different for each
214+
working tree. This section is about the sharing rules and how to access
214215
refs of one working tree from another.
215216

216217
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
218+
with `refs/` are shared. Pseudo refs are ones like `HEAD` which are
219+
directly under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are
220+
exceptions, however: refs inside `refs/bisect` and `refs/worktree` are not
220221
shared.
221222

222223
Refs that are per working tree can still be accessed from another
223-
working tree via two special paths, main-worktree and worktrees. The
224-
former gives access to per-worktree refs of the main working tree,
224+
working tree via two special paths, `main-worktree` and `worktrees`. The
225+
former gives access to per-working tree refs of the main working tree,
225226
while the latter to all linked working trees.
226227

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.
228+
For example, `main-worktree/HEAD` or `main-worktree/refs/bisect/good`
229+
resolve to the same value as the main working tree's `HEAD` and
230+
`refs/bisect/good` respectively. Similarly, `worktrees/foo/HEAD` or
231+
`worktrees/bar/refs/bisect/bad` are the same as
232+
`$GIT_COMMON_DIR/worktrees/foo/HEAD` and
233+
`$GIT_COMMON_DIR/worktrees/bar/refs/bisect/bad`.
233234

234-
To access refs, it's best not to look inside GIT_DIR directly. Instead
235+
To access refs, it's best not to look inside `$GIT_DIR` directly. Instead
235236
use commands such as linkgit:git-rev-parse[1] or linkgit:git-update-ref[1]
236237
which will handle refs correctly.
237238

238239
CONFIGURATION FILE
239240
------------------
240-
By default, the repository "config" file is shared across all working
241+
By default, the repository `config` file is shared across all working
241242
trees. If the config variables `core.bare` or `core.worktree` are
242243
already present in the config file, they will be applied to the main
243244
working trees only.
244245

245246
In order to have configuration specific to working trees, you can turn
246-
on "worktreeConfig" extension, e.g.:
247+
on the `worktreeConfig` extension, e.g.:
247248

248249
------------
249250
$ git config extensions.worktreeConfig true
@@ -255,7 +256,7 @@ configuration in this file with `git config --worktree`. Older Git
255256
versions will refuse to access repositories with this extension.
256257

257258
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
259+
is gone. If they exist in `$GIT_DIR/config`, you must move
259260
them to the `config.worktree` of the main working tree. You may also
260261
take this opportunity to review and move other configuration that you
261262
do not want to share to all working trees:
@@ -268,59 +269,59 @@ do not want to share to all working trees:
268269
DETAILS
269270
-------
270271
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
272+
`$GIT_DIR/worktrees` directory. The private sub-directory's name is usually
272273
the base name of the linked working tree's path, possibly appended with a
273274
number to make it unique. For example, when `$GIT_DIR=/path/main/.git` the
274275
command `git worktree add /path/other/test-next next` creates the linked
275276
working tree in `/path/other/test-next` and also creates a
276277
`$GIT_DIR/worktrees/test-next` directory (or `$GIT_DIR/worktrees/test-next1`
277278
if `test-next` is already taken).
278279

279-
Within a linked working tree, $GIT_DIR is set to point to this private
280+
Within a linked working tree, `$GIT_DIR` is set to point to this private
280281
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
282+
`$GIT_COMMON_DIR` is set to point back to the main working tree's `$GIT_DIR`
282283
(e.g. `/path/main/.git`). These settings are made in a `.git` file located at
283284
the top directory of the linked working tree.
284285

285286
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
287+
`$GIT_DIR` or `$GIT_COMMON_DIR` depending on the path. For example, in the
287288
linked working tree `git rev-parse --git-path HEAD` returns
288289
`/path/main/.git/worktrees/test-next/HEAD` (not
289290
`/path/other/test-next/.git/HEAD` or `/path/main/.git/HEAD`) while `git
290291
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.
292+
`$GIT_COMMON_DIR` and returns `/path/main/.git/refs/heads/master`,
293+
since refs are shared across all working trees, except `refs/bisect` and
294+
`refs/worktree`.
294295

295296
See linkgit:gitrepository-layout[5] for more information. The rule of
296297
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.
298+
`$GIT_DIR` or `$GIT_COMMON_DIR` when you need to directly access something
299+
inside `$GIT_DIR`. Use `git rev-parse --git-path` to get the final path.
299300

300-
If you manually move a linked working tree, you need to update the 'gitdir' file
301+
If you manually move a linked working tree, you need to update the `gitdir` file
301302
in the entry's directory. For example, if a linked working tree is moved
302303
to `/newpath/test-next` and its `.git` file points to
303304
`/path/main/.git/worktrees/test-next`, then update
304305
`/path/main/.git/worktrees/test-next/gitdir` to reference `/newpath/test-next`
305306
instead.
306307

307-
To prevent a $GIT_DIR/worktrees entry from being pruned (which
308+
To prevent a `$GIT_DIR/worktrees` entry from being pruned (which
308309
can be useful in some situations, such as when the
309310
entry's working tree is stored on a portable device), use the
310311
`git worktree lock` command, which adds a file named
311-
'locked' to the entry's directory. The file contains the reason in
312+
`locked` to the entry's directory. The file contains the reason in
312313
plain text. For example, if a linked working tree's `.git` file points
313314
to `/path/main/.git/worktrees/test-next` then a file named
314315
`/path/main/.git/worktrees/test-next/locked` will prevent the
315316
`test-next` entry from being pruned. See
316317
linkgit:gitrepository-layout[5] for details.
317318

318-
When extensions.worktreeConfig is enabled, the config file
319+
When `extensions.worktreeConfig` is enabled, the config file
319320
`.git/worktrees/<id>/config.worktree` is read after `.git/config` is.
320321

321322
LIST OUTPUT FORMAT
322323
------------------
323-
The worktree list command has two output formats. The default format shows the
324+
The `worktree list` command has two output formats. The default format shows the
324325
details on a single line with columns. For example:
325326

326327
------------
@@ -333,10 +334,10 @@ $ git worktree list
333334
Porcelain Format
334335
~~~~~~~~~~~~~~~~
335336
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
338-
if the value is true. The first attribute of a worktree is always `worktree`,
339-
an empty line indicates the end of the record. For example:
337+
label and value separated by a single space. Boolean attributes (like `bare`
338+
and `detached`) are listed as a label only, and are present only
339+
if the value is true. The first attribute of a working tree is always
340+
`worktree`, an empty line indicates the end of the record. For example:
340341

341342
------------
342343
$ git worktree list --porcelain

0 commit comments

Comments
 (0)