Chamly Idunil
Chamly Idunil

Reputation: 1872

Why is 'git clone' not working with submodule?

I could not clone the parent project with submodules. Only parent project was cloned.

I tried with

  1. git clone --recurse-submodules <repor>
  2. git clone --recursive <repo

And so many options.

Do I need to configure my Git environment to support submodules?

Here it is repositories I have tried.

Parent project

https://github.com/chamlyidunil/test-submodule-project

Common project (submodule)

https://github.com/chamlyidunil/common-utility

And it really helps you if you can provide example Git commands for the whole cycle.

  1. git pull (get update with sub modules)

My Git version is 2.15.1 (Apple Git-101).

Upvotes: 0

Views: 2717

Answers (1)

bk2204
bk2204

Reputation: 76459

Your project has a .gitmodules file, but it doesn't have an actual submodule commit checked in.

If you want to add a submodule, you should use git submodule add to add the submodule and then commit the result. That will add the submodule commit into the repository, which your repository is lacking at the moment.

So, for example, in your personal clone of the parent project, you'd remove the current .gitmodules file and run git submodule add https://github.com/chamlyidunil/common-utility.git common-utility and then commit the result.

Upvotes: 2

Related Questions