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

git submodule ignores --git-dir

From
FGFilip Gospodinov <filip.gospodinov@monetas.net>
Date
Sep 10, 2015, 20:06 UTC
Message-ID
<55F1E2AB.3020507@monetas.net>
Hi!

I use the `--git-dir` flag in some scripts such that I don't need to `cd` back and forth. Recently, I've discovered that `--git-dir` does not seem to work correctly for `git submodule`. Here is a short snippet to reproduce that behavior:

mkdir repo1 subm (cd subm; git init; git commit -m 1 --allow-empty) (cd repo1; git init; git submodule add ../subm subm; git commit -m "add subm") git clone repo1 repo2 git --git-dir=$PWD/repo2/.git submodule update --init

which errors with the following output:
No submodule mapping found in .gitmodules for path 'subm'

But this works: cd repo2; git --git-dir=$PWD/.git submodule update --init

I know that for this particular use case I can just use `git clone --recursive` and that other use cases can be worked around by using `cd`. Still, I wonder if the behavior I discovered is a bug or if it's expected.

git --version git version 2.5.1

Thanks you! Filip

Next: Jens Lehmann
Message 1 of 4 in “git submodule ignores --git-dir”
  1. Filip GospodinovSep 10, 2015
  2. Jens LehmannSep 11, 2015
  3. John KeepingSep 11, 2015
  4. Filip GospodinovSep 14, 2015

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.