简体   繁体   English

将git repo追加到原始repo

[英]Append git repo to original repo

I have the following situation: 我有以下情况:

I have an old git repo, that I at one point abandoned because I started using Bazaar instead, mainly because I wanted to use LaunchPad. 我有一个旧的git repo,因为我开始使用Bazaar,所以有一次我放弃了它,主要是因为我想使用LaunchPad。 At the time, it was not possible to convert the original git repo to bzr format, so I simply started a new bzr repo based on the last git commit. 当时,不可能将原始的git repo转换为bzr格式,因此我只是根据上一个git commit来启动一个新的bzr repo。

Now, years later, I have reversed my decision, and I want to go back to git. 现在,几年后,我改变了决定,我想回到git。 I have converted my bzr repo to git, but now I'd like to stack the new repo on the old one, so I have the entire 10+ years of history for the project. 我已经将我的bzr存储库转换为git,但是现在我想将新存储库堆叠在旧存储库上,因此我拥有该项目整整10多年的历史。 The first commit in the "new" repo is very similar to the last commit in the "old" repo. “新”存储库中的第一个提交与“旧”存储库中的最后一个提交非常相似。

I have researched how to merge git repositories, but the cases people describe are mostly merging subtrees. 我研究了如何合并git存储库,但是人们描述的情况主要是合并子树。 That is not what I want. 那不是我想要的。 I merely want to stack the "new" repo on top of the "old" repo. 我只想将“新”存储库堆叠在“旧”存储库之上。

I suppose it is possible to manually extract every commit in the "new" repo and committing them on the "old" repo, preserving the date and commit message, but I am wondering if there's a smarter way to do it. 我想可以手动提取“新”存储库中的每个提交并将其提交到“旧”存储库中,从而保留日期和提交消息,但是我想知道是否有更聪明的方法来做到这一点。

You can do this sort of grafting with the replace command. 您可以使用replace命令进行这种嫁接。 From the Git book : Git书中

You can graft one history onto the other by replace ing the earliest commit in the new line with the latest commit on the older one. 通过replace新行中最早的提交replace为较旧的最新提交,可以将一个历史移植到另一历史上。 This is nice because it means that you don't actually have to rewrite every commit in the new history, as you would normally have to do to join them together (because the parentage affects the SHA-1s). 这很好,因为这意味着您实际上不必重写新历史记录中的每个提交,而通常需要将它们连接在一起(因为亲子关系会影响SHA-1)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM