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

Re: Bug? clone ignores --git-dir

From
Jeff King <peff@peff.net>
Date
Nov 27, 2019, 11:51 UTC
Message-ID
<20191127115124.GE22221@sigill.intra.peff.net>
In-Reply-To
<7d28416e-c927-4cd3-bac2-d8bfd02ce949@nottheoilrig.com>
On Tue, Nov 26, 2019 at 11:07:27AM -0700, Jack Bates wrote:
Show 14 quoted lines
> If you `git rebase --exec 'gulp runtests-parallel --runners user'` this
> project, the tests perform Git operations on various subprojects [1], but
> because Git exports `GIT_DIR` and `GIT_WORK_TREE`, they end up operating on
> the parent project instead.
> 
> Adding `--git-dir` and `--work-tree` overrides `GIT_DIR` and `GIT_WORK_TREE`
> [2], forcing the tests to operate on the correct repositories, however
> `clone` ignores `--git-dir`:
> 
> > git init repository
> > git --git-dir git-dir clone repository directory
> I'd expect Git to create a directory `git-dir` and put the index, etc.
> there, but instead it creates `directory/.git`, as usual. I'm not sure if
> this is a bug or the expected behavior?

This is the expected behavior. "clone" and "init" are special in that they are creating _new_ repositories, so they explicitly ignore the any notion of the current repository.

I'm not quite sure what you're trying to do. I'd think:
  git clone --bare repository git-dir

would do what you want, but then I'm not sure why you're specifying "directory" in the first place, or what you expect to happen. Are you looking for clone's --separate-git-dir option, perhaps?

-Peff
Previous: Jack BatesNext: Junio C Hamano
Message 2 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.