0

I have a library that relies on a number of other components. I've setup the main project and then added a number of submodules using git submodule add [url] [path].

The original project works fine. Each time I added a submodule it was cloned to the correct directory.

- Main project
-- Sub project [cloned correctly]

After that I pushed the original project to git. Now when I clone the main project, the sub project directories appear but they're empty.

- Main project
-- Sub project just empty folder

The .gitmodules is populated correctly but in the newly cloned main project, the .git/modules folder is empty.

No commands like git submodule sync or git submodule update work. However, if I manually re-add the modules they then appear in the directories without having to be re-downloaded. It says:

Reactivating local git directory for submodule

It's almost like git has the modules stored internally but doesn't add them to the file system.

What's the best practice for a situation like this?

James Andrews
  • 3,257
  • 3
  • 31
  • 45
  • possible duplicate of [How to \`git clone\` including submodules?](http://stackoverflow.com/questions/3796927/how-to-git-clone-including-submodules) – umläute May 21 '15 at 21:11

2 Answers2

0

you are missing

git submodule init

in the clones (before you can successfully run git submodule update)

umläute
  • 28,885
  • 9
  • 68
  • 122
0

After cloning you need to:

git submodule init 
git submodule update

OR

clone the main repo and get submodules at the same time with:

git clone --recursive URL
Guillermo Mansilla
  • 3,779
  • 2
  • 29
  • 34