Subtrees versus submodules
In general, subtrees are easier to use and less tricky. Many people go with submodules, because of the better built-in tooling (they have their own Git command, namely, git submodule
), detailed documentation, and similarity to the Subversion externals, making them feel falsely familiar. Adding a submodule is very simple (just run git submodule add
), especially compared to adding a subtree without the help of third-party tools such as git subtree
or git subrepo
.
The major difference between subtrees and submodules is that, with subtrees, there’s only one repository, which means just one life cycle. Submodules and similar solutions use nested repositories, each with its own lifeline.
Though submodules are easy to set up and fairly flexible, they are also fraught with peril, and you need to practice vigilance while working with them. The fact that the submodules are opt-in also means that the changes touching the submodules demand a manual update...