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 ?
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.
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 .
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.
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.
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 meNo 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With