What is a git submodule?

A Git submodule is a Git repository placed inside another Git repository. The main project keeps only a link to a specific commit of the submodule, and both have their own separate history.

It is useful when a project uses a shared library or a component which has its own repository and its own team. The links are saved in the .gitmodules file.

git submodule add https://github.com/user/library.git libs/library
git clone --recurse-submodules <url>
git submodule update --init --recursive

The common problem is that people forget to initialize or update the submodule after a clone. See Git Submodule.


Learn more about the similar topics:
Tutorials
Git Tag
Git Submodule
Git Hooks
Exercises & Assignments
Create an annotated tag for a release
Interview Questions & Answers
What is a git submodule?
What is the difference between a lightweight tag and an annotated tag in Git?
What are Git hooks?
What is git blame?
What is git bisect?