Skip to content
Home Tutorials Roadmaps Courses Classroom Training Blog
Log in Join free
Git Beginner Free

Git Submodules

Lesson 14 of 17 · Submodules & Subtree 82%
1. Getting Started
What is Git?
2. Branching & Merging
Branches & Merging
3. Stashing & Undoing
Git Stash Undoing Changes
5. Tags & Releases
Git Tags
6. Git Hooks & Config
Git Hooks Git Configuration
9. Submodules & Subtree
Git Submodules
10. GitHub Actions
GitHub Actions CI/CD
11. Git Worktrees
Git Worktrees

Submodules let you include other Git repositories as subdirectories.

Syntax

GIT
git submodule add URL path
git submodule init
git submodule update
git submodule foreach git pull
Git Submodules
BASH
# Add submodule
git submodule add https://github.com/user/lib.git libs/my-lib

# Clone with submodules
git clone --recurse-submodules https://github.com/user/repo.git

# Update submodules
git submodule update --remote

# Initialize submodules after clone
git submodule init
git submodule update

Up next

GitHub Actions CI/CD

Lesson 15 of 17 · GitHub Actions