Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty Git submodule folder when repo cloned

I have one repo hosted at https://github.com/aikiframework/json . On my local copy, I added a submodule using the command

git submodule add [email protected]:jcubic/json-rpc.git json-rpc

Then I did a commit and push, and the changes appear on GitHub (I can click on it). But when I clone the repo

git clone https://github.com/aikiframework/json.git

the submodule folder json-rpc is empty.

What am I missing here? Did I forget about something? Why is that folder empty?

like image 367
jcubic Avatar asked Sep 29 '22 19:09

jcubic


People also ask

Does git clone pull submodules?

It automatically pulls in the submodule data assuming you have already added the submodules to the parent project. Note that --recurse-submodules and --recursive are equivalent aliases.

How do I get rid of dirty submodule?

You can fix it by: either committing or undoing the changes/evolutions within each of your submodules, before going back to the parent repo (where the diff shouldn't report "dirty" files anymore). To undo all changes to your submodule just cd into the root directory of your submodule and do git checkout .

Why you should not use git submodules?

This is because of some major drawbacks around git submodules, such as being locked to a specific version of the outer repo, the lacking of effective merge management, and the general notion that the Git repository itself doesn't really know it's now a multi-module repository.


1 Answers

OK I found it, needed to add --recursive when cloning the repo.

So the clone command ends up as:

git clone https://github.com/aikiframework/json.git --recursive

Note that if you forgot the --recursive flag you can do (thanks to @Amber):

git submodule update --init
like image 294
jcubic Avatar answered Oct 13 '22 04:10

jcubic