Initialize Nested Repos With git submodule

Fetch and check out the exact commits a project's submodules reference.

macOSpackagesgitcliLow risk
Run git submodule update --init --recursive after cloning a project with submodules.

01Command

Command
$ git submodule update --init --recursive

02What 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

RiskLow risk
RequirementsGit 2.20+ (install with Homebrew or Xcode Command Line Tools)
CompatibilitymacOS with Git installed (Homebrew or Xcode Command Line Tools)
!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

Last verified: 2026-10-13 · Category: Developer