Reputation: 181
I've already searched and found many answers regarding that topic (submodule, subtree,...) but I don't really know which is the 'best solution' for my specific problem having two repos in one directory when both repos share the same folder structure/names.
So my partner and I code together on some specific files. Our repo (on github) have the following folder structure.
├───AddOns
│ └───SidiFolder2
│ <file.cs>
│ <file2.cs>
│ <file4.cs>
│ <file5.cs>
├───Indicators
│ ├───Sidi
│ │ └───SidiFolder2
│ │ <file.cs>
These folders/files are locally stored in default vs2022 source folder at the moment (%USERPROFILE%\source\Repos\OurName\OurProject).
Beside that there is a 'big directory' in %USERPROFILE%\DOCUMENTS\LOCALFOLDER\* which I also have source controlled with/to github (only for me - no other person has access to that one).
My problem now is this LOCALFOLDER has some folders in it which we also use/have in our repo mentioned at top.
So please have a look at the structure below. I have this 'big' (private) repo on github (only for me - no one should see/use those folders/files) and we have a 'small' repo on github which my partner and I use for coding where at the end a few folders/files have to be placed in the 'big' LOCALFOLDER structure. So all the folder/files marked with "⋘⋘⋘⋘" should be used from our 'small' repo.
Both repos should be manageable for me in visual studio comm. edition 2022 (with git ui tools there if possible).
What I've read git submodule
or git subtree
are only possible if they are located in its own/extra folder (which isn't the case here, also subtree is still not manageable with vs2022 git ui possibilities).
├───AddOns ⋘⋘⋘⋘
│ └───SidiFolder2 ⋘⋘⋘⋘
│ <file.cs> ⋘⋘⋘⋘
│ <file1.cs>
│ <file2.cs> ⋘⋘⋘⋘
│ <file3.cs>
│ <file4.cs> ⋘⋘⋘⋘
│ <file5.cs> ⋘⋘⋘⋘
│ <other_files_here.cs>
├───BarsTypes
├───bin
├───ChartStyles
├───de-DE
├───DrawingTools
│ └───Sidi
├───es-ES
├───ExportNinjaScript
├───fr-FR
├───ImportTypes
├───Indicators ⋘⋘⋘⋘
│ ├───AB
│ ├───GB
│ ├───Settlement
│ ├───Sidi ⋘⋘⋘⋘
│ │ └───SidiFolder2 ⋘⋘⋘⋘
│ │ <file.cs> ⋘⋘⋘⋘
│ ├───CD
│ └───EF
│ └───GH
│ <many_files_here.cs>
│ <many_files_here2.cs>
├───it-IT
├───ko-KR
├───MarketAnalyzerColumns
├───OptimizationFitnesses
├───Optimizers
├───PerformanceMetrics
├───pt-PT
├───ru-RU
├───ShareServices
├───Strategies
├───SuperDomColumns
└───zh-Hans
Upvotes: 1
Views: 954
Reputation: 14753
git submodule
and git subtree
are indeed two alternative setups when dealing with a "monorepo" − a big repository aggregating several different projects… that can have their own history upstream.
Two remarks:
git subtree
is much more lightweight than git submodule
, so if you have the choice between both approaches, I would straightforwardly recommend relying on git subtree
.
as you pointed out, both approaches require that the "common files" are located in a single subfolder.
As a result, if you cannot use git subtree
as is, you should either refactor the layout of your repositories (at least to separate the shared files from private files in different subfolders), or devising some "handcrafted" Bash-or-Powershell scripts to help you automating the sync…
Alternatively, you may want to try an interesting combination of these 2 git extensions: vcsh and myrepos. Albeit the documented use case is a bit different than yours (managing one's dotfiles…)
Otherwise as suggested by @Schwern, maybe you would just need to rely on git branch
es management?
Upvotes: 1