Git submodule
Definition
A Git submodule integrates a separate repository at a fixed version into a parent project.
A Git submodule is an independent repository within the working tree of another repository. The parent project holds a reference to a specific commit of the submodule. Both repositories have separate histories and must be managed accordingly.
Simply explained
Your main project remembers which version of an included subproject belongs to its own state.
Why it matters in practice
Submodules allow targeted versioning of shared components but increase the requirements for setup, updating, and collaboration.
Example from business
Possible example: Two applications include a shared library as a submodule and adopt new library versions only after their own review.
Limits and pitfalls
- A clone does not necessarily contain all submodule files immediately. Changes in the subproject and updating its reference in the main project are separate steps.
Origin & history
Submodules connect multiple separate Git histories without merging them into one. The recorded commit explicitly shows the dependency of a project state.
Use in mid-sized companies
- An operation documents the initialization of submodules and checks both the included commit and its interaction with the main project during updates.
Frequently asked questions
Does a submodule always automatically follow the latest state?
No. The decisive factor is initially the commit recorded in the main project; updates must be consciously adopted.
Sources
- git-submodule. · Git-Projekt (o. J.): git-submodule.
- gitsubmodules. · Git-Projekt (o. J.): gitsubmodules.
Editorially reviewed on: