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

Adding and Merging with Subtree

Learn the commands for adding an external repository as a subtree and how to pull updates from its upstream.

Subtree: Integrating External Code

Welcome! In this lesson, we'll dive into Git Subtree, a powerful way to integrate another Git repository directly into your project.

Unlike submodules, subtree merges the external repository's history into your own, making it feel like a native part of your project.

Why Use `git subtree add`?

Subtree offers a simpler workflow than submodules for many cases. Here are a few benefits:

  • No special commands: Once added, you work with subtree content like regular files.
  • Single repository: No separate .git directories or complex submodule initializations.
  • Easier for consumers: Others cloning your project don't need to learn special submodule commands.

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