subrepositories
Subrepositories are repositories that exist inside another repository, treated as independent version-controlled units while being integrated under a single top-level project. They arise in distributed version control to modularize codebases by isolating components with their own histories and access controls, yet keeping them part of a unified repository structure.
In Git, the two most common mechanisms are submodules and subtrees. Submodules record a fixed commit of
Other systems implement subrepositories in different ways. For example, Mercurial supports subrepositories declared in a .hgsub
Advantages of subrepositories include modular development, easier reuse, and independent versioning or ownership boundaries. Drawbacks include
Best practices recommend evaluating the need for subrepositories versus monorepo or vendor approaches, pinning to fixed