Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 674
voila Avatar asked Dec 22 '15 04:12

voila


People also ask

How do I clone a submodules repo?

The list of steps required to clone a Git repository with submodules is: Issue a git clone command on the parent repository. Issue a git submodule init command. Issue a git submodule update command.

How do I clone a recursive repository?

2.1. If you want to clone a repository including its submodules you can use the --recursive parameter. If you already have cloned a repository and now want to load it's submodules you have to use submodule update .

Does git clone include submodules?

Cloning a Project with Submodules If you pass --recurse-submodules to the git clone command, it will automatically initialize and update each submodule in the repository, including nested submodules if any of the submodules in the repository have submodules themselves.

What does recursively clone submodules mean?

git clone(1) --recursive. Clone a repository into a new directory. --recursive, --recurse-submodules After the clone is created, initialize all submodules within, using their default settings. This is equivalent to running git submodule update --init --recursive immediately after the clone is finished.


1 Answers

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.

like image 70
VonC Avatar answered Sep 29 '22 10:09

VonC