结合保留历史/分支的不相关的git存储库 [英] combining unrelated git repositories retaining history/branches

查看:98
本文介绍了结合保留历史/分支的不相关的git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有3个独立的git仓库(每个仓库都有一些分支),我们希望将它们合并成一个保存完整历史记录和访问分支的能力,如下所示:



所以这就是我们所拥有的。 3回购:

  /A/.git 
/B/.git
/C/.git

我们希望有一个包含3个子目录的超级回购:

  super / .git 
super / A
super / B
super / C

并且在切换到分支特性1(最初是在repo B中引入的时候说,repo C尚不存在)我们期望得到的结果是:

pre $ $ $ $ $ $超级/ B

我们已阅读组合多个git仓库,但使用git-stitch-repo时遇到了问题,它基本上像广告一样工作,只有超级仓库中缺少大量的提交(没有任何错误消息将指向一个问题)。



有什么想法可以在这里做错吗?

编辑
我们知道子模块和子树合并,但都不是一种选择。这应该是一次性操作。我们需要回购一次,永远加入。

编辑
可能是一个简单的方法来放置基本相同的问题:假设我们有一个3个完全无关的分支的回购。我们可以将它们无冲突地合并到一个分支(因为它们不共享文件)。现在看历史时,我们看到3个不相关的提交分支和他们聚集在一起的一个点。但我们希望看到的是由所有3个分支交错(通过日期/时间)提交组成的一个分支。

解决方案

splice_repos 是我写的一个工具,它将交错从不同的存储库提交到一个新的存储库中,以便同名分支得到合并历史记录承诺按历史顺序),而不是仅仅在最后与不同分支上的单独历史合并。有博客条目描述了背后的理由。 p>

we're having 3 separate git repositories (each with some branches) which we'd like to combine into one keeping full history and the ability to access the branches, like so:

so this is what we have. 3 repos:

/A/.git
/B/.git
/C/.git

and we'd like to have one super-repo with 3 subdirectories:

super/.git
super/A
super/B
super/C

and say when switching to branch feature1 (which was originally in repo B, introduced at a time that repo C didn't exist yet) we'd expect the result to be:

super/.git
super/A
super/B

we've read Combining multiple git repositories but had troubles using git-stitch-repo which basically worked as advertised only that quite a large number of commits were missing in the super-repo (without any error messages that would point to a problem).

any idea what we could be doing wrong here?

EDIT we are aware of submodules and subtree-merging, but both are not an option. this is supposed to be a one time operation. we need the repos joined once and forever.

EDIT probably a simpler way to put basically the same question: say we have one repo with 3 totally unrelated branches. we can merge them without a conflict to one branch (since they share no files). now when looking at the history we see 3 unrelated branches of commits and the one point where they come together. but what we'd like to see is one branch made up of the interleaved (by date/time) commits of all 3 branches.

解决方案

splice_repos is a tool I wrote that interleaves commits from different repositories into a new repository, so that same-named branches get merged histories (as though they were committed to in historical order), rather than just being merged at the end with separate histories on different branches. There's a blog entry describing the rationale behind it.

这篇关于结合保留历史/分支的不相关的git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆