QamoosTech
Git & CollaborationIntermediate

Git Submodule

PronunciationGIT SUB-mod-yool

Definition

A Git repository stored inside another repository and pinned to one specific commit. It lets a project include another project's code, while the parent repository records which version it uses.

Where you hear it

Projects that share common code between repos.

Examples

  • Clone with --recurse-submodules to get the nested repo.
  • The submodule points to an old commit.
  • The shared theme lives in a submodule, so each site pins the version it uses.

Common mistake

Updating the child repo but forgetting to commit the new pointer in the parent repo.

Don't confuse with

Git Submodule vs Git Subtree: A submodule keeps the repositories as separate entities linked by a pointer, whereas a subtree merges the contents of the child repository directly into the parent's history.

Say it at work

  • In a meeting or chatI'm having trouble pulling the latest changes; did you remember to update the Git submodule pointer?
  • In an email or ticketPlease ensure the Git submodule is initialized correctly in the CI pipeline to avoid build failures.