55

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.

1
  • 1
    you could also re-clone the repository using "git clone --recursive <URL>" Commented Jan 28, 2014 at 17:45

2 Answers 2

94

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

Sign up to request clarification or add additional context in comments.

3 Comments

Wow, that did the trick. I don't know why git isn't smart enough to do that in the first place. Oh well, thanks!
git assumes that if you didn't init the submodule, it's because you don't want it. This is confusing to newcomers, but it can be extremely useful in cases where the submodule is optional.
It's always surprised me that you can't just do: git submodule add --recursive <git path>.
1

You could also do:

git clone --recurse-submodules <REPO_URI>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.