Search code examples
gitgit-submodules

git add submodule of remote


I have a submodule in a git remote repository. I cloned the repository before the remote submodule was created.

How can I add the submodule of the remote repository?

I tried the following:

$ git submodule init
$ git submodule update

and

$ git submodule update --init --recursive

But none of those commands worked—there is no .gitmodules file.

The remote has a .gitmodules file with information about the submodule. In the remote repository:

$ git submodule
+79444cf2aaa9279b4838f52b81cc40ad3f116771 Appendix

The .gitmodules file was added to the repository as evidenced by:

$ git status .gitmodules
# On branch master
nothing to commit (working directory clean)

If .gitmodules had not been committed this command would have stated that it was untracked.


Solution

  • It looks like the .gitmodules file does not yet exist in your local repository. Make sure that this file has been committed in the remote repository and that you have since pulled this commit to your local repository.