Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding git submodule that contains another submodule?

I'm working on a project in one git repository (A) that is including another git repository (B), which in turn includes a third git repository (C). In A, I added B via:

git submodule add https://github.com/blt04/sfDoctrine2Plugin.git plugins/sfDoctrine2Plugin 

Click here, and you can see where B references C: https://github.com/doctrine/doctrine2

After doing my git submodule add, my plugins/sfDoctrine2Plugin/lib/vendor/doctrine folder (should contain C) is empty. I tried doing a git submodule update --recursive as per this StackOverflow answer, but it still didn't import the files to that path. I'm at a loss as to what to do here.

like image 999
Matt Huggins Avatar asked Jan 05 '11 04:01

Matt Huggins


People also ask

Can git submodules have 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.

Can I have nested git repositories?

Git allows you to include other Git repositories called submodules into a repository. This allows you to track changes in several repositories via a central one. Submodules are Git repositories nested inside a parent Git repository at a specific path in the parent repository's working directory.

How do I sync submodule?

git submodule sync synchronizes all submodules while git submodule sync -- A synchronizes submodule "A" only. If --recursive is specified, this command will recurse into the registered submodules, and sync any nested submodules within.

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.


1 Answers

You need to do git submodule update --init --recursive. The problem here is the submodule C is never being initialized in the first place.

like image 180
Lily Ballard Avatar answered Sep 24 '22 18:09

Lily Ballard