git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Jeff KingNext: Jack Bates
Message 3 of 4 in “Bug? clone ignores --git-dir”
  1. Jack BatesNov 26, 2019
  2. Jeff KingNov 27, 2019
  3. Junio C HamanoNov 27, 2019
  4. Jack BatesNov 27, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.