Skip to content

jasonniebauer/Git-Submodule-Tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published