如何将一个git存储库添加到另一个git存储库的子文件夹中?

Sat*_*ato 7 git

我在一个名为AA的文件夹中有一个GIT存储库,我有第二个名为BB的 GIT存储库.

我想将AA存储库作为子文件夹导入BB存储库.

之前:

AA
 |- .git
 |-  A/
 |-  fileA

BB
 |- .git
 |-  B/
 |-  fileB
Run Code Online (Sandbox Code Playgroud)

后:

BB
 |- .git # new .git with both AA and BB .git infos
 |-  B/
 |-  fileB
 |-  AA/      # <== no .git anymore
 |-  AA/A/
 |-  AA/fileA
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

cfi*_*cfi 3

如果文件夹结构不同,git mv可以解决这个问题:

  1. 克隆原始存储库,
  2. git mv将所有内容放入新的子目录中AA
  3. 然后使用它作为源存储库来克隆这个问题答案