0Pricing
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.

Monorepos and Git Submodules is a free DevOps Bootcamp lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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

Frequently asked questions

Is the “Monorepos and Git Submodules” lesson free?

Yes — the full text of “Monorepos and Git Submodules” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.

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; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

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