Transforming a subfolder into a subtree or submodule
The first issue that comes to mind while thinking of the use cases of subprojects in Git is about having the source code of the base project ready for such division.
Submodules and subtrees are always expressed as subdirectories of the superproject (the master project). You can’t mix files from different subsystems in one directory.
Experience shows that most systems use such a directory hierarchy, even in monolithic repositories, which is a good beginning for modularization efforts. Therefore, transforming a subfolder into a real submodule/subtree is fairly easy and can be done in the following sequence of steps:
- Move the subdirectory in question outside the working area of a superproject to have it beside the top directory of the superproject. If it is important to keep the history of a subproject, consider using
git subtree split
, orgit filter-branch --subdirectory-filter
or its equivalent, perhaps together...