Nested Git submodules not cloning properly with –recursive flag

I’m setting up an internal mirror of a github project. The project has submodules in it, which also have submodules within the original submodules.

I’ve mirrored all of the repositories individually, and have updated the .gitmodules files in all of the repositories to point to the internal mirror locations. All of the repositories clone individually with –recursive without any issues. For some reason, when I try to clone any repository that has nested submodules, the first set of submodules is read correctly from .gitmodules and cloned, but then the submodules within that submodule will all try to clone from their original github URLs. I can’t figure out where these URLs are coming from, because the nested submodules have all had their .gitmodules files updated.

Has anyone ran into this before? Any ideas?

  • How to commit a git repository inside another git repository
  • git - default push to --recurse-submodules=check
  • How to configure Teamcity git plugin to init submodules NON-recursively
  • Working with Git submodules without .gitmodules
  • How can I commit with cloned submodule in my repo?
  • How can I have linked dependencies in a git repo?
  • modified content in git submodule, but git submodule says up to date
  • Moved folder into submodule, now getting “Untracked files would be overwritten” message
  • 2 Solutions collect form web for “Nested Git submodules not cloning properly with –recursive flag”

    When you’re doing initial setup with git submodule update --init --recursive you’re taking the .gitmodules values straight from the recorded commits. I’m thinking when you updated the .gitmodules files you didn’t do it depth-first, so while the .gitmodules recorded in the first-level submodule was updated and added, its own submodules hadn’t yet been updated and added so the recorded commit still had the original .gitmodules file.

    This is the best way to do this:

    git submodule update --init --recursive

    Does this solve your problem?

    Git Baby is a git and github fan, let's start git clone.