简体   繁体   中英

Is it possible using one git repo to manage several git repos?

I have one and only one git repo in a remote server named, say, allinone , but I actually have several projects, say proj1 , proj2 , proj3 , and I store all these projects into allinone , like this:

allinone
 |- .git
 |-  proj1/
 |-  proj2/
 |-  proj3/

Here is how things go(if it is possible):

  1. I created allinone git repo
  2. I created proj1 git repos, do some developing, committing, and done.
  3. I created a proj1 branch in allinone repo, and 'import' proj1 into allinone 's proj1 branch with all commit logs.
  4. Same for proj2, proj3.
  5. Later I can checkout proj1 branch out into an independent directory.

Is it possible? Or are there any suggestions? I dont want to buy another repo.

Git itself doesn't require that there be any relation between branches in a repository. So, you could create as many local repositories that you want and have all of those push to a single remote repository. If you carefully setup the refspecs used by each local repository, it could even appear very much like you have separate remotes for each local repository.

But, it's possible that whatever provider that you're using would check for that type of use, especially if they're charging per repository.

You're much less likely to run into issues if you instead find a way to have a separate remote repository for each project. The git wiki has a list of hosting sites , a number of which will allow hosting of private repositories for free.

This is bad architecture. You're killing yourself by managing your repo's this way.

I have found that there is never a valid reason to have more than one repo per project.

I can only imagine what it must be like to have to constantly merge all of those repo's to keep them updated.

It seems to me like you should just create a separate branch for each "project", which will more easily allow you to maintain history, workflow, and do less merging. However, even this would be flawed because no matter what you do, you have to be leaving a large opportunity for merge conflicts in your project. If I were you, I would do anything I possibly could to cut down to your "allinone" repo, and just manage that by checking out feature branches when you're doing work that pertains to a certain "project".

Best of luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM