jasonniebauer / Git-Submodule-Tutorial

Learn to use Git submodules.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Learn to use Git submodules.