Any experts on Git sub-modules here?

So, I have a Git repository that was created by a colleague and that contains a number of sub-modules. Usually, when I have worked with Git sub-modules before, then a simple clone --recursive would fetch the "main" repository and all the nested sub-modules. But, with this "problematic" repository, the sub-directories for the sub-modules are just empty after the clone (with "--recursive" flag)! There's no error message or anything. Just nothing. Of course, the subsequent build will fail with missing files 🙄

Now, we also have GitLab as a Web-GUI for our Git server. In my other repositories, when I have some sub-modules, GitLab is smart: I can just click on the sub-module "folder" and then GitLab automatically navigates to the corresponding repository. But, with the "problematic" repository, if I click on the sub-module "folder" in GitLab, simply nothing happens. Again, nor error or anything.

How can I see or change the alleged "address" (URL) of a sub-module?

Regards.
Last edited on
cat .gitmodules
If starting from scratch, you need:
git submodule update --init --recursive
^^ I have to run that every time I swap branches, not just on startup, to be sure the branch and its sm versions are in synch.
cat .gitmodules

Thanks. But the repository does not have a .gitmodules file. And that might be the problem here 😕

Strangely, Git doesn't complain about the missing file.

But I wonder: How did it ever work?

(Before you ask: I already tried contacting the person who created the repo, but to no avail)

If starting from scratch, you need:
git submodule update --init --recursive

I think this should not be needed, if we have used the "--recursive" flag with the clone command already.

Anyways, I tried git submodule update --init --recursive too, but it didn't do anything (also no error message).
Last edited on
But the repository does not have a .gitmodules file. And that might be the problem here

Indeed there must be this file present for git to know about submodules, I have repo with one submodule and the file is present.

I however cloned normally, there was no need submodule --recursive flag.

Do you have latest git version? I know that recent git simplified submodule management, for more info see:

https://github.blog/2016-02-01-working-with-submodules
You need --init on git submodule update to fetch everything the first time. You don't need it after that.

As I understand it, you're fetching the for the first time, so ...
You need --init on git submodule update to fetch everything the first time. You don't need it after that.

As I understand it, you're fetching the for the first time, so ...


Yeah, but my problem is that the .gitmodules file is absent from the repo, so Git does not do anything about the sub-modules.

(Interestingly, there is no error message or at least a hint about the missing file)
Last edited on
Interestingly, there is no error message or at least a hint about the missing file


An analogy:

There is no gun.
Why nobody is shooting?
Well because there is no gun.

You need to tell repo owner to re-add submodules or make your own copy of .gitsubmodule file.

Simply create a file and copy\paste contents from file in github repo into your own copy.
Yeah, but Git definitely has marked the sub-folders in question as sub-modules. For example, in GitLab, they have a sub-module icon:
https://i.imgur.com/MHEeoaI.png

Only the URL to fetch those sub-modules from is not defined, because of the missing .gitmodules file.

So I'd be nice if git submodule update --init at least gave some sort of warning/hint on why it skipped the sub-module(s) 😏
Last edited on
Topic archived. No new replies allowed.