git submodule not pulling files in submodules

geekdenz picture geekdenz · Apr 7, 2012 · Viewed 25.9k times · Source

I thought I had it all worked out with this new project and thought that git submodules are the way to to develop and deploy my application.

Set up my git repo (Drupal) and initialized it with the 7.12 tag of Drupal. Made my own branch. Then added the modules that are needed under sites/all/modules/contrib with git submodule add --branch 7.x git://path/to/drupal/module sites/all/modules/contrib/module

and then I thought, by pushing my repo to github, I would be able to simply pull it and then it would pull all the submodules into the deployment path. However, all my modules are not pulled, even if I do: git submodule foreach git pull or git submodule init followed by git submodule update

Turns out, I was wrong. Do I now need to redo everything in another way? If yes, please tell me how, if not, great, please let me know.

Answer

Andrew T Finnell picture Andrew T Finnell · Apr 7, 2012

You forked the Drupal repo? Does it already have sub modules added in .gitmodules? If so you only needed to clone their branch and perform

git submodule init
git submodule update

You don't need to re-add their own sub modules to the repo.

Now if you want to add additional submodules you have to perform git submodule init; git submodule update every time you clone the repo. It will not automatically get the submodules.