Initialize Nested Repos With git submodule
Fetch and check out the exact commits a project's submodules reference.
Run git submodule update --init --recursive after cloning a project with submodules.
01Command
Command
$ git submodule update --init --recursive02What it does
Submodules pin a dependency at a specific commit, and a plain clone leaves their directories empty. This command initializes, clones and checks out each nested repository, including nested submodules, which is the standard CI step for such projects.
03Risk
!Warning: Submodules can drift from the parent repository; commit and push inside the submodule before updating the pointer.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- git-submodule documentationEvidence: Documents git submodule, including --init and --recursive.
Last verified: 2026-10-13 · Category: Developer