Here\'s part of the contents of my .gitmodules
file:
[submodule \"src/static_management\"]
path = src/static_management
url = gi
.git/config
git submodule init
commandgit pull origin master
It should works now
There seems to be a lot of confusion here (also) in the answers.
git submodule init
is not intended to magically generate stuff in .git/config (from .gitmodules). It is intended to set up something in an entirely empty subdirectory after cloning the parent project, or pulling a commit that adds a previously non-existing submodule.
In other words, you follow a git clone
of a project that has submodules (which you will know by the fact that the clone checked out a .gitmodules file) by a git submodule update --init --recursive
.
You do not follow git submodule add ...
with a git submodule init
(or git submodule update --init
), that isn't supposed to work. In fact, the add will already update the appropriate .git/config if things work.
EDIT
If a previously non-existing git submodule was added by someone else, and you do a git pull
of that commit, then the directory of that submodule will be entirely empty (when you execute git submodule status
the new submodule's hash should be visible but will have a -
in front of it.) In this case you need to follow your git pull
also with a git submodule update --init
(plus --recursive
when it's a submodule inside a submodule) in order to get the new, previously non-existing, submodule checked out; just like after an initial clone of a project with submodules (where obviously you didn't have those submodules before either).
I had the same problem.
.gitmodules
had the submodule, but after a git submodule init
command it wasn't in .git/config
.
Turns out the developer who added the submodule also added the submodule directory to the .gitignore
file. That doesn't work.