简体   繁体   English

如何将多个存储库克隆到现有存储库中?

[英]How to git clone multiple repos into an existing repo?

Assuming there are three repos containing the files below:假设有三个包含以下文件的存储库:

  1. git@github.com:me/project.git git@github.com:me/project.git

     code/file1 code/file2 code/file3
  2. git@github.com:me/extras1.git git@github.com:me/extras1.git

     code/file4 code/file5 code/file6
  3. git@github.com:me/extras2.git git@github.com:me/extras2.git

     code/file7 code/file8 code/file9

So far I have cloned project.git , so I have the following directory structure:到目前为止,我已经克隆了project.git ,所以我有以下目录结构:

project/code/file1
project/code/file2
project/code/file3

How would you clone (or merge?) extras1.git and extras2.git so that you end up with the directory structure below AND still be able to do a git pull for each repo:你将如何克隆(或合并?) extras1.gitextras2.git以便你最终得到下面的目录结构并且仍然能够为每个 repo 做一个git pull

project/code/file1
project/code/file2
project/code/file3
project/code/file4
project/code/file5
project/code/file6
project/code/file7
project/code/file8
project/code/file9

I believe the following will do it (assuming each repo has a single branch called "master")我相信以下会做到这一点(假设每个 repo 都有一个名为“master”的分支)

git remote add extras1 git@github.com:me/extras1.git
git fetch extras1
git merge --allow-unrelated-histories extras1/master
git remote add extras2 git@github.com:me/extras2.git
git fetch extras2
git merge --allow-unrelated-histories extras2/master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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