为了账号安全,请及时绑定邮箱和手机立即绑定

组合多个git存储库

组合多个git存储库

Git
千万里不及你 2019-07-22 10:35:02
组合多个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能帮我的忙吗?
查看完整描述

3 回答

?
翻阅古今

TA贡献1780条经验 获得超5个赞

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

查看完整回答
反对 回复 2019-07-22
?
largeQ

TA贡献2039条经验 获得超7个赞

也许,简单地(类似于前面的答案,但使用更简单的命令)在每个单独的旧存储库中提交一个提交,将内容移动到一个适当命名的子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
...

然后你将保存你的历史,但将继续一个回购。


查看完整回答
反对 回复 2019-07-22
  • 3 回答
  • 0 关注
  • 428 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信