Skip to content

Commit 3ac4b85

Browse files
committed
git: update documentation for --git-dir
git --git-dir <path> is a bit confusing and sometimes doesn't work as the user would expect it to. For example, if the user runs `git --git-dir=<path> status`, git will not be able to figure out the work tree path on its own and will assign the work tree to the user's current work directory. When this assignment is wrong, then the output will not match the user's expectations. This patch updates the documentation to make it clearer. Signed-off-by: Heba Waly <[email protected]>
1 parent 2323784 commit 3ac4b85

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Documentation/git.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,15 @@ foo.bar= ...`) sets `foo.bar` to the empty string which `git config
110110
Do not pipe Git output into a pager.
111111

112112
--git-dir=<path>::
113-
Set the path to the repository. This can also be controlled by
114-
setting the `GIT_DIR` environment variable. It can be an absolute
115-
path or relative path to current working directory.
116-
113+
Set the path to the repository (i.e. the .git folder). This can also be
114+
controlled by setting the `GIT_DIR` environment variable. It can be
115+
an absolute path or relative path to current working directory.
116+
117+
Note that --git-dir=<path> is not the same as -C=<path>.
118+
It's preferrable to set --work-tree=<path> as well when setting
119+
--git-dir to make sure Git will run your command across the correct
120+
work tree.
121+
117122
--work-tree=<path>::
118123
Set the path to the working tree. It can be an absolute path
119124
or a path relative to the current working directory.

0 commit comments

Comments
 (0)