moki
moki

Reputation: 61

Multiple git repos in one folder?

Is it possible to have a folder structure on git with multiple repos in it?

For example:

<owner>
    <folder 1>
        <folder 1.1>
            <repo>
        <folder 1.2>
            <repo>
        . . .
    <folder 2>
        <folder 2.1>
            <repo>
        <folder 2.2>
            <repo>
        . . .
    <folder 3>
        <folder 3.1>
            <repo>
        <folder 3.2>
            <repo>
        . . .

Upvotes: 1

Views: 1145

Answers (3)

nos
nos

Reputation: 20862

You can surely organize your repos into that folder structure and the question is to how to manage them. I wrote a command-line tool gita for this purpose.

It can display the status of all repos, including the edit status, the relation to remote branch, etc. It also batch executes commands from any working directory.

You can also group the repos. For your project structure, you can run

gita add -a <owner>

which will automatically generate hierarchical groups:

  • owner: containing all repos
  • owner-folder1: repos in it
  • owner-folder1-folder1.1: repos in there
  • etc

Then gita ll owner, gita ll owner-folder1, etc will display the relevant information. gita <command> owner will batch run the command on repos in the owner group. You can also run any command on any specified repos from any working directory too.

There are other functionalities such as setting context, defining custom commands, etc. Installation is pip3 install -U gita. You can find more information on github.

enter image description here

Upvotes: 0

Grrzly
Grrzly

Reputation: 63

If you plan to have this structure in your remote repo (gitlab, github) I don’t see any obstacles. The same is good for a local repo.

Basically gitlab allows you to create subgroups (folder1, folder 1.2, ...) and put whatever amount of repositories inside this subgroups as you wish.

In your case:

  1. owner is a base subgroup
  2. folder 1 is the level 1 subgroup
  3. folder 1.1 is the level 2 subgroup
  4. repo is the repo of the level 2 subgroup
  5. folder 1.2 is the level 2 subgroup
  6. repo is the repo of the level 2 subgroup

You don’t need git submodules if I got your question right. Submodules are needed in case if you have to inject one repo inside another as a folder and have its content synchronised.

Upvotes: 0

SzybkiDanny
SzybkiDanny

Reputation: 263

Assuming the owner is also a git repository, then take a look at git submodules. Otherwise, I don’t see why not.

Upvotes: 2

Related Questions