Git Submodules

4 months ago

Adding a Submodule

git submodule add <repository-url> <path>
  • repository-url - remote Git repository to add

  • path - relative path to the submodule, including itself

Clone with Submodules

git clone --recurse-submodules <main-repository-url>

Initializing Submodules after Cloning

git submodule init
git submodule update

Update Submodules

git submodule update --remote

Remove a Submodule

git submodule deinit <path>
git rm <path>

Execute Commands in a Submodule

git submodule foreach '<command>'

Check Submodule Status

git submodule status

Pulling Changes with Submodules

git pull --recurse-submodules

David D.

David Dyess .com

Copyright © 1999 - 2024