我得到了两个具有以下文件夹结构的回购:
> folder1 >.git > file1 > file2 > folder2 >.git > file3 > file4
> repo >.git > folder1 > file1 > file2 > folder1 > file3 > file4
我如何在Git中做到这一点,而不丢失任何一个以前独立的存储库的历史?
我想以下几点应该行得通:
调整回购 folder1 拥有正确的内部结构。
folder1
cd folder1 mkdir folder1 git mv file1 folder1/file1 git mv file2 folder1/file2 git commit -a
回购协议也是如此 folder2
folder2
cd folder2 mkdir folder2 git mv file3 folder2/file3 git mv file4 folder2/file4 git commit -a
git pull
cd folder1 # the top one, not the one we have created in the 1st step. git pull /path/to/folder2
或者,将两者合并为新创建的回购协议。
mkdir repo cd repo git init git pull /path/to/folder1 git pull /path/to/folder2
你可以找到解决方案 here .