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

Re: add/init all git submodules that are referenced in .gitmodules

From
Jeff King <peff@peff.net>
Date
Oct 6, 2021, 19:28 UTC
Message-ID
<YV3444Bvvfzp37Di@coredump.intra.peff.net>
In-Reply-To
<CA+KyZp75fjj9T0LjkpEjLMVf5KNguNZ1Ycxbb26ZnCGrK5zLAQ@mail.gmail.com>
On Tue, Oct 05, 2021 at 04:52:00PM -0700, Alexander Mills wrote:
Show 5 quoted lines
> I am looking for this feature:
> 
> https://stackoverflow.com/a/69458406/1223975
> 
> it is really confusing as to why it doesn't exist
I'm not sure I understand what is being asked for.

If you just want to initialize and populate all of the modules in .gitmodules (which is what I thought your subject line was asking for), then:

  git submodule update --init

will do that (though of course if you are cloning anyway, you can just say "--recurse-submodules).

But reading the original SO question, it is about finding repositories in the current directory that _aren't_ submodules, and then adding them. But those ones wouldn't be referenced in .gitmodules.

For that problem, no, I don't think there's an easy command, and you have to dig for them (though "git ls-files -o --exclude-standard" is perhaps a good way to locate them). But it's also not something I'd expect to be a very common operation, which is why there's not an existing command to do it.

-Peff
Previous: Alexander Mills
Message 2 of 2 in “add/init all git submodules that are referenced in .gitmodules”
  1. Alexander MillsOct 5, 2021
  2. Jeff KingOct 6, 2021

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.