[英]How to merge GIT repo's with common code BUT NO common ancestry
How can I merge two git repos with common code but no common ancestry?如何合并两个具有通用代码但没有共同祖先的 git 存储库?
Here is what happened:这是发生的事情:
What we are desiring now is to have ONE repo with我们现在想要的是拥有一个 repo
Preferably with all branches that existed in both intact最好是所有存在于两者中的分支都完好无损
Here are two sample repos这是两个示例存储库
https://github.com/patrickwolf/sandbox_repoRoot
https://github.com/patrickwolf/sandbox_repoRoot
https://github.com/patrickwolf/sandbox_repoNewhttps://github.com/patrickwolf/sandbox_repoNew
Thanks!谢谢!
The easiest would be a graft/replace.最简单的将是移植/替换。 That will allow you to connect both histories without much trouble, to the best of my knowledge.
据我所知,这将使您能够毫不费力地将这两个历史联系起来。 Check https://stackoverflow.com/a/6802005/2437508
检查https://stackoverflow.com/a/6802005/2437508
But if you don't mind rewriting the later part of history, you could rewrite the history of the second repo on top of the first.... you just need to find the two revisions that share the same content so that you work from there.但是,如果您不介意重写历史的后半部分,则可以在第一个 repo 之上重写第二个 repo 的历史......您只需要找到共享相同内容的两个修订,以便您从那里。
Let's assume you have a local repo that can see both repos as remotes, old
and new
.假设您有一个本地存储库,可以将两个存储库视为遥控器,
old
和new
。
The first revision in branches of new
is branch new/first
, which matches in content with old/main
. new 分支中的第一个修订版是分支
new
new/first
,其内容与old/main
匹配。 If we wanted to rewrite new/main
on top of old/main
:如果我们想在
old/main
之上重写new/main
main :
git rebase --rebase-merges --onto old/main new/first new/main
That should do.应该这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.