Skip to content

Latest commit

 

History

History
75 lines (59 loc) · 1.34 KB

README.md

File metadata and controls

75 lines (59 loc) · 1.34 KB

Git Submodule Tutorial

Include other Git repositories in repositories.

Table of Contents

Git Submodules to the Rescue

Your First Submodule

Add a repository as a submodule

git submodule add <repo>

Update a Submodule

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

Clone a Project with Submodules

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

Clone a Project with Submodules and their contents

git clone --recursive <project-repo>

Update all submodules for a project already cloned

git submodule foreach git pull origin master

Reference Guide 1
Reference Guide 2