Git & GitHub Professional Workflow · 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 Git & GitHub Professional Workflow lesson on CoddyKit. This is 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 Git & GitHub Professional Workflow learning path, and your progress syncs across the web and the CoddyKit app. The Git & GitHub Professional Workflow 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 Git & GitHub Professional Workflow 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
12
Lessons
48

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. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Git & GitHub Professional Workflow course, upgrade to CoddyKit PRO. The Git & GitHub Professional Workflow 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 Git & GitHub Professional Workflow 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 Git & GitHub Professional Workflow?

No prior experience is required. Git & GitHub Professional Workflow 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 Git & GitHub Professional Workflow lesson?

Yes. Every Git & GitHub Professional Workflow 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 Git & GitHub Professional Workflow