DevOps Bootcamp · Lesson

Monorepos and Git Submodules

Learn the trade-offs between monorepos and multi-repo setups, and how Git submodules embed one repository inside another.

Lesson 4 of 413 steps

Monorepos and Git Submodules is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 4 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

Monorepo vs. Multi-repo

A monorepo stores many projects in one repository. A multi-repo setup keeps each project in its own repo. Both are common at scale.

Why Teams Choose Monorepos

Monorepos make it easy to:

  • Share code across projects
  • Refactor across boundaries atomically
  • Use one CI and one versioning scheme

Monorepo Challenges

Large monorepos can grow huge, slowing clones and CI. Tooling like sparse checkout and build caches helps manage this.

What is a Submodule?

A submodule is a separate Git repository embedded inside another repo at a specific commit. The outer repo tracks which commit of the inner repo to use.

Adding a Submodule

Embed an external repo at a path with git submodule add.

git submodule add https://github.com/org/shared-lib libs/shared

The .gitmodules File

Git records each submodule's path and URL in a tracked .gitmodules file at the repo root.

[submodule 'libs/shared']
  path = libs/shared
  url = https://github.com/org/shared-lib

Cloning with Submodules

A normal clone leaves submodule folders empty. Use the recursive flag to fetch them too.

git clone --recurse-submodules https://github.com/org/app

Initializing Existing Submodules

If you already cloned, pull the submodule contents with init and update.

git submodule update --init --recursive

Updating a Submodule

Submodules stay pinned to a commit. To move to the latest, update inside it and commit the new pointer in the parent.

git submodule update --remote libs/shared
git add libs/shared
git commit -m 'Bump shared lib'

Submodules vs. Subtree

git subtree is an alternative that merges another repo's content directly, avoiding the pinned-pointer complexity but losing clean separation.

Choosing an Approach

Use a monorepo for tightly coupled projects, submodules to embed a shared but independently-versioned library, and multi-repo when teams are fully autonomous.

Quick Check

Test your understanding of monorepos and submodules.

Recap

You learned about monorepos and submodules:

  • Monorepos centralize many projects; multi-repos separate them
  • Submodules embed a repo pinned to a commit via .gitmodules
  • Clone with --recurse-submodules
  • Subtree is an alternative embedding strategy
Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

Is the “Monorepos and Git Submodules” lesson free?

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Monorepos and Git Submodules”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

What will I learn in “Monorepos and Git Submodules”?

Learn the trade-offs between monorepos and multi-repo setups, and how Git submodules embed one repository inside another. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 4 of 4.

How long does the “Monorepos and Git Submodules” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Git in IDEs & Development Tools
  2. Enterprise Git Solutions
  3. Scaling Git for Large Teams
  4. Monorepos and Git Submodules
← Back to DevOps Bootcamp