I have 3 git repos with similar organization and some duplicate directories between them. They are subprojects of one big project.
Proj1/
.git/
feature1_lib/
feature1_app/
feature1/ <- specific to Proj1
feature2_lib/
...
Proj2/
.git/
feature1_lib/
feature1_app/
feature1/ <- specific to Proj2
feature2_lib/
...
Proj3/
.git/
feature1_lib/
feature1_app/
feature1/ <- specific to Proj3
feature3_lib/ <- specific to Proj3
feature3_app/ <- specific to Proj3
feature3/ <- specific to Proj3
...
They was developed simultaneously, but have slightly different history.
Proj1/
...
commit4 "Commit specific to Proj1."
commit5 "Add code to feature1_lib."
commit6 "Fix bugs in feature1_lib."
commit7 "Refactoring in feature1_lib."
...
Proj2/
...
commit6 "Import changes from Proj1." <- after commit7 in Proj1
commit7 "Commit specific to Proj2."
commit8 "Fix bugs in feature2_lib."
commit9 "Add code to feature2_lib."
...
and so on.
Now I am seeking for options to cut and glue duplicated parts. I think it should look like this
Proj1_2_common/
.git/
...
Proj1_2_3_common/
.git/
...
Proj1/
.git/
...
Proj2/
.git/
...
Proj3/
.git/
...
I read about subtree and submodule, but do not fully understood. Why I have to make subtree if I can just point in my projects to certain directory? That is, instead of making subtree from "feature1_lib/"
I can simply reconfig my projects to look into "Proj1_2_3_common/feature1_lib/"
.
So what is the better options here from yours point of view? What is the easiest one? How to deal with such messy history to have some references after movement?