Skip to content

Commit f5e025a

Browse files
pcloudsgitster
authored andcommitted
Documentation: always respect core.worktree if set
The value of core.worktree in a ".git/config" is honored even when it differs from the directory that has the ".git" directory as its subdirectory. This is likely to be a misconfiguration, so warn users about it. Also, drop the part of the documentation that incorrectly claimed that we ignore such a misconfigured value. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0622f79 commit f5e025a

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

Documentation/config.txt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,24 @@ false), while all other repositories are assumed to be bare (bare
297297
= true).
298298

299299
core.worktree::
300-
Set the path to the working tree. The value will not be
301-
used in combination with repositories found automatically in
302-
a .git directory (i.e. $GIT_DIR is not set).
300+
Set the path to the root of the work tree.
303301
This can be overridden by the GIT_WORK_TREE environment
304302
variable and the '--work-tree' command line option. It can be
305-
a absolute path or relative path to the directory specified by
306-
--git-dir or GIT_DIR.
307-
Note: If --git-dir or GIT_DIR are specified but none of
303+
an absolute path or a relative path to the .git directory,
304+
either specified by --git-dir or GIT_DIR, or automatically
305+
discovered.
306+
If --git-dir or GIT_DIR are specified but none of
308307
--work-tree, GIT_WORK_TREE and core.worktree is specified,
309-
the current working directory is regarded as the top directory
310-
of your working tree.
308+
the current working directory is regarded as the root of the
309+
work tree.
310+
+
311+
Note that this variable is honored even when set in a configuration
312+
file in a ".git" subdirectory of a directory, and its value differs
313+
from the latter directory (e.g. "/path/to/.git/config" has
314+
core.worktree set to "/different/path"), which is most likely a
315+
misconfiguration. Running git commands in "/path/to" directory will
316+
still use "/different/path" as the root of the work tree and can cause
317+
great confusion to the users.
311318

312319
core.logAllRefUpdates::
313320
Enable the reflog. Updates to a ref <ref> is logged to the file

0 commit comments

Comments
 (0)