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