Subtree merge or submodules are for a component-based development: two different but coherent set of files combined together.
Each set of files is in its own directory, because they can be branched or labelled independently (submodules), or together (subtree merge, while keeping the ability to get back an history of their own).
Both are requiring a separate directory though.
But what you are describing ("Base Project
" is in root directory, growing in "project 1
" or "project 2
") is about a system-based approach: all components merged into one large component: one large set of file which will always evolve together, as one unit.
So you can have one branch per project: branch1
for CMS-projet1
, branch2
for CMS-project2
, and so on.
But if you need to report projectx
-specific modifications or CMS-specific modifications back to their original (and separate) repos, then make said specific changes in dedicated branches, and then combine those changes:
branchp1
would be for changes affecting project1
branchc1
would be for changes affecting CMS
branch1
would be the result of the merge from branchp1
and branchc1
(same thing for branch2
)
You can then export those changes as patches:
- from
branchp1
to project1
repo
- from
branchc1
to CMS
repo
The inconvenient is that Git won't remember what has already been merged back to the original repos, but that would allow you to report the common history developed in your CMS-projectx
set of files back to your original CMS
and projectx
repos.
Note: if you don't want to manage 2 extra branches, another solution is to:
- make sure each commit only include CMS modification OR project modification
- leave a commit message which helps to distinguish them ("
[CMS] my CMS modification comment...
", or "[Project1] my project1 modification comment...
"
- use the script
git-extract-patches
to export as patches only the right commits.