Use case - multiple clones in one project directory

Although I’ve used CM tools before, I’m new to GitLab. I have a use case I’m trying to implement but could use some help. Let’s say we have two halves of a code base. Repository 1 holds files A and C. Repository 2 holds files B and D. We have another repository 3 which holds different files B and D. The idea is that repositories 2 and 3 are modular and either-or can be added to a working project directory. Now, when a project needs to save to repositories, we can push from the same project directory back to repositories 1 and 2 (or 3). As a special note, the file listings are mutually exclusive among complementary repositories, meaning that no files in repository 1 are in repository 2 and vice versa.

I did get as far as being able to rename the .git directory using “git init --separate-git-dir” which can allow more than one clone in a directory by using “git --git-dir=/opt/myproject.git”. However if I try actually clone more than one repository into a project directory I get the “directory not empty” error. Is there a way to bend GitLab to do what I want with too much chicanery, or am I thinking about the whole scheme incorrectly?

Hi @arcadebench
The native GIT solution for your use-case is submodules.
In Repository 1 you will configure submodules for Repository 2 and Repository 3. Only requirement is that each submodule must be in dedicated directory. i.e you cannot have something like this:

.
├── file1
├── docs
│   ├── main
│   │   ├── index.html                         <-- from repository 1
│   │   ├── app.html                           <-- from repository 2
│   │   ├── user.html                          <-- from repository 3

Hi @balonik , thanks very much for your quick reply. Unfortunately what you’ve pictured is exactly what I’m trying to do. I could modify the code-base to compartmentalize the files from different repositories, but it would be a nightmare.

The other thought I had was to simply clone into separate directories and then hand-assemble them into one project directory. The problem there is that once I’m ready to push I would first have to piece-out the files back into their respective directories, which sounds very error-prone.