Is there any problem with git repositories nested into each other?

I have a bunch of git repositories and would like to consolidate them into a single one.

I was wondering whether there is anything speaking against just running a git init in the enclosing directory of those separate repos?

Or do I need to ungit all seperate repos before consolidating them into a larger structure?

I don’t think nested repositories will work as expected, as by default git will include anything in the main folder as part of its repository – excluding ./.git – so changing branches in the nested repositories will likely have unexpected consequences.

Then you can delete the .git folder in each sub-repository to have a single big repository. Although, depending on what projects you have inside and how you handle them, it may not advisable: grouping projects “living” together makes sense, grouping unrelated projects less so.

Maybe take a look at submodules:

1 Like