0PricingLogin
Git Advanced: Monorepo, Submodules & Workflows · Lesson

Subtree vs. Submodule Comparison

Analyze the pros and cons of both Git Subtree and Submodules to help you choose the best strategy for your project.

Subtree vs. Submodule: The Showdown

Welcome to the final lesson in our Git Subtree mini-course! We've explored what Git Subtree is and how to use it. Now, it's time to compare it with Git Submodules.

Both tools help manage external dependencies within a main repository, but they do so in fundamentally different ways. Understanding these differences is key to choosing the right strategy for your project.

Submodules: External Repositories

Recall that Git Submodules allow you to embed one Git repository inside another as a subdirectory. The main repository stores a reference to a specific commit in the submodule's repository.

  • Separate Histories: Each submodule maintains its own independent Git history.
  • Pointers, Not Copies: The parent repository only stores a pointer to the submodule's commit, not its actual content.
  • Decentralized Development: Ideal for when you need to contribute directly to the upstream dependency.

All lessons in this course

  1. Introduction to Git Subtree
  2. Adding and Merging with Subtree
  3. Subtree vs. Submodule Comparison
  4. Pushing Changes Back Upstream with Subtree Split
← Back to Git Advanced: Monorepo, Submodules & Workflows