1

I have the following structure for the my project:

-- main_repo
---- sub1
---- sub2
---- sub3

Right now I'm implementing the CI for all projects, and the submodules all depends on the main_repo. I could run this CI from the main repo, but I really like to run it from each repo.

So, I was wondering if the git clone command can clone the submodule and also the parent repo. Is it possible?

Example:

$ git clone sub1 --clone-parent

Or there is a better solution for this case?

Ramon Medeiros
  • 2,272
  • 2
  • 24
  • 41
  • 1
    Does this answer your question? [How to "git clone" including submodules?](https://stackoverflow.com/questions/3796927/how-to-git-clone-including-submodules) – smac89 Dec 07 '19 at 18:23
  • No. I want to clone the submodule (sub1) and somehow clone the parent. It's the opposite – Ramon Medeiros Dec 07 '19 at 19:20
  • Then make the "parent" a submodule of your projects and use the link I posted to clone the submodules along with the parent. – smac89 Dec 07 '19 at 19:40

2 Answers2

1

Yes. This is possible.

You need to add --recurse-submodule to the git clone command. This will actually clone all the sub modules with the parent

Shabz
  • 17
  • 2
1

A remote git repository has no idea whether or not it is a submodule. There is no metadata of any sort that says "this module was added as a submodule to some other repository".

Think of the relationship between submodules and parents: a particular git repository may be a submodule of many unrelated modules. This is especially true if the module implements some sort of basic library.

Even a repository that itself contains several submodules may in turn be a submodule of another repository somewhere else.

larsks
  • 277,717
  • 41
  • 399
  • 399