8.5 Using Git Submodules to Track External Repositories

Sometimes you need to track multiple repositories as if they’re all in the same repository. This might be because of a dependency on some third-party library or possibly because your in-house project has been divided into multiple projects to help make them more manageable.

Git allows you to track external repositories through what it calls submodules. These allow you to store a repository within another repository while keeping the two histories completely independent. Those coming from a Subversion background might recognize these as svn:externals.

Adding a New Submodule

Let’s demonstrate this behavior. First we need to create a new repository that will house our submodule repository. ...

Get Pragmatic Version Control Using Git now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.