组合多个git存储库

组合多个git存储库

假设我有一个看起来像

phd/code/
phd/figures/
phd/thesis/

由于历史原因,这些机构都有自己的git存储库。但是我想把它们组合成一个,来简化一些事情。例如,现在我可能会做两组更改,并且必须执行以下操作

cd phd/code
git commit 
cd ../figures
git commit

现在只要表演就好了

cd phd
git commit

似乎有几种方法可以使用子模块或从我的子存储库中提取,但这比我想要的要复杂一些。至少,我很高兴

cd phd
git init
git add [[everything that's already in my other repositories]]

但这看起来不像是一条直线。里面有什么东西吗?git能帮我的忙吗?


千万里不及你
浏览 426回答 3
3回答

翻阅古今

git-stitch-repo将处理git-fast-export --all --date-order在命令行上给出的git存储库上,并创建一个适合于git-fast-import这将创建一个新的存储库,其中包含新提交树中的所有提交,该树尊重所有源存储库的历史记录。

largeQ

也许,简单地(类似于前面的答案,但使用更简单的命令)在每个单独的旧存储库中提交一个提交,将内容移动到一个适当命名的子dir中,例如:$ cd phd/code $ mkdir code # This won't work literally, because * would also match the new code/ subdir, but you understand what I mean: $ git mv * code/ $ git commit -m "preparing the code directory for migration"然后将三个单独的repos合并为一个新的,方法如下:$ cd ../.. $ mkdir phd.all $ cd phd.all $ git init $ git pull ../phd/code ...然后你将保存你的历史,但将继续一个回购。
打开App,查看更多内容
随时随地看视频慕课网APP