voila
voila

Reputation: 1666

git --recursive doesn't clone submodule

I learned that to download submodules with main repository we can use --recursive option when cloning main repository.

I did the same git clone --recursive [email protected]:passion/academy.git

I found that it only create a empty directory of submodule but not downloaded its code.

Do we need to do extra stuff like git submodule update --init --recursive ? If yes then what is the use of --recursive flag when cloning main repository ?

Upvotes: 7

Views: 6703

Answers (2)

Jerry Chen
Jerry Chen

Reputation: 389

I had a similar issue. A few things to check:

  1. Check your .gitmodules file:
% cat .gitmodules
[submodule "src/mysubmodule"]
    path = src/mysubmodule
    url = myurl/mysubmodule.git
  1. Check your .git/config file and make sure the submodule url listed is the same as in .gitmodules:
% cat .git/config
...
[submodule "src/mysubmodule"]
    url = myurl/mysubmodule.git
    active = true
  1. Finally, check the url and make sure this is the correct url (should be the same as what you type in a "git clone" of that submodule).

Upvotes: 2

VonC
VonC

Reputation: 1330102

If you are using a recent enough git, and it still does not clone submodules, that means those empty folders are not submodules but nested git repo.

A nested repo is recorded in its parent repo as a gitlink, but there would not be any .gitmodules files associated to it.

health-check seem to be a nested git but not sure when cloning give me No submodule mapping found in .gitmodules for path for health-check .. is it necessary for nested git repos to have entry in .gitmodules ?

If you want your nested git repo to be recognized and managed as a submodule, yes.

As illustrated by your next question, it is possible that the lack of path entry in .gitmodules for health-check prevents hellospawn (which seems to be a legit submodule) to be checked out.

Upvotes: 3

Related Questions