如何连接两个 git 历史记录?
我有两个相关的 git 存储库。也就是说,一个内容是另一个内容的前身。我想以某种方式将存储库 A 的完整历史记录添加到存储库 B 中,以便 A 的提示将成为存储库 B 的第一个变更集的父级?两者的历史都是相当线性的。
这可能吗?
I have two git repositories that are tangentially related. Namely, content of one was a predecessor of the other. I would like to somehow prepend the full history of depository A to the depository B, so that tip of A would be a parent of the very first changeset of repository B? Histories in both are pretty linear.
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用嫁接文件(
.git/info/grafts
),您可以在其中覆盖提交的父级(例如projectB
的第一个父级为最新的projectA
)另请参阅“什么是 .git/info/grafts for?" 和 "如何在前面添加过去到 git 存储库?”了解有关此操作的更多信息。
skalee 关于文章“Git 的评论 :嫁接存储库”(来自SO用户Ben Straub)具体的例子。
在一行中,如 建议 作者:ssokolow)
那里。现在我们的历史记录如下所示:
在一行中,如 由ssokolow建议)
作为 Qix 评论下面:
You could try using the graft file (
.git/info/grafts
) where you could overwrite the parenthood of a commit (like the first ofprojectB
having for parent the latest ofprojectA
)See also "What are .git/info/grafts for?" and "How to prepend the past to a git repository?" for more on this manipulation.
skalee comments about the article "Git: Grafting repositories" (from SO user Ben Straub) for a concrete example.
(in one line, as suggested by ssokolow)
There. Now our history looks like this:
(in one line, as suggested by ssokolow)
As Qix comments below: