如何将多个repos克隆到现有的repo中?

时间:2017-09-29 00:32:21

标签: git github

假设有三个包含以下文件的repos:

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

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

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

    code/file7
    code/file8
    code/file9
    
  4. 到目前为止,我已经克隆了 project.git ,所以我有以下目录结构:

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

    你将如何克隆(或合并?) extras1.git extras2.git ,以便最终得到下面的目录结构并仍然能够做到每个回购邮件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
    

1 个答案:

答案 0 :(得分:1)

我相信以下内容会做到这一点(假设每个仓库都有一个名为“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
相关问题