Re: Bug? clone ignores --git-dir
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 27, 2019, 12:33 UTC
- Message-ID
- <xmqqh82pv6qi.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <7d28416e-c927-4cd3-bac2-d8bfd02ce949@nottheoilrig.com>
Jack Bates <bk874k@nottheoilrig.com> writes:
> ... repositories, however `clone` ignores `--git-dir`:
An intentional design decision (and it may be an unfortunate one by now [*1*]) was to have the GIT_DIR (hence --git-dir) talk about the *source side* of the clone, not the destination, e.g.
cd /home/me/working/tree export GIT_DIR=/home/me/repo/sitory export GIT_WORK_TREE=$(pwd)
# the above told Git that /home/me/working/tree has a # checkout but its repository body is not anywhere in its # subdirectory -- it is /home/me/repo/sitory.
# now we clone the repository we are currently working on # without GIT_DIR applying to the source side, it won't # work. git clone . /else/where
And we cannot allow /home/me/repo/sitory (i.e. GIT_DIR for the source repository) become the GIT_DIR for the resulting /else/where repository (you'd be cloning to yourself).
[Footnote]
*1* with use of "git worktree" gaining traction, perhaps the need to
create local clone out of the shared/same GIT_DIR may have
diminished.