Mid Version Control

What are submodules in Git, and when would you use them?

A Git submodule is a repository inside another repository — useful for including shared

components or libraries.

Example:

You have multiple microservices that share a common authentication library. Instead of

duplicating it, you include it as a submodule:

git submodule add

libs/auth

Follow:

Pros: Keeps shared code centralized.

Cons: Requires careful syncing; new contributors must initialize submodules using:

git submodule update --init --recursive

More from Developer Essentials

All questions for this course