Include other Git repositories in repositories.
Table of Contents
- Git Submodules to the Rescue
- Your First Submodule
- Update a Submodule
- Clone a Project with Submodules
Add a repository as a submodule
git submodule add <repo>
Get the latest submodule repository updates
cd <path-to-submodule>
git pull
cd ..
git status
git commit -am "Update submodule to latest version"
git push
git clone <project-repo>
cd <path-to-submodule>
The submodule directory will be empty, so we need to initialize and update with contents
git submodule update -init
Shorthand would be:
git submodule update -i
git clone --recursive <project-repo>
git submodule foreach git pull origin master