sojourner
sojourner

Reputation: 117

How can one consolidate a number of .git folders & corresponding remote repositories into one super repository?

I'm trying to consolidate about 15 local git folders (with subfolders & files) / 15 repositories into 1 super folder / 1 super repository while maintaining each local folders git history and relationship to its respective repository (to become a sub folder on git).

Is this possible? What are the steps one would need to take to make it happen?

Upvotes: 0

Views: 94

Answers (3)

poke
poke

Reputation: 388403

You could combine all those repositories into a single one by having separate sets of independent branches for each one. This would also mean that you would share the same object database for all repositories, which removes redundancy. But it would also mean that you cannot really work with a single subrepository alone without taking the rest of the big one as well.

Note that in general, it is recommended to keep the repositories separate. It’s not really a problem either. The best example is GitHub’s Gist where they have separate repositories for each Gist although most of them just contain a single file.

So don’t spend time trying to combine those (probably not that related) repositories; just use them separately.

Upvotes: 0

patthoyts
patthoyts

Reputation: 33223

You might want to take a look at the repo tool that is used in Android development. The android source tree consists of many git repositories tied together using repo. It may be tricky to find out how to configure the repo XML configuration file but the Android tree should provide a useful example.

Upvotes: 1

aymericbeaumet
aymericbeaumet

Reputation: 7342

You should have a Git submodule approach.

First, just create a simple git repository. Then, add each git folder you want to consolidate using the following command (from the main repo root):

git submodule add repo_url local_path

Each git submodule will kept its own history.

Upvotes: 2

Related Questions