将一个 Git 存储库拆分为多个 - 分支成为分支
我在 SVN 中有一个项目,我正在将其迁移到 Git。该项目由一个“核心”产品(在主干下)组成,然后该产品在同一存储库中进行分支,并用作为我们将产品推出到的每个客户进行定制的起点。
在我看来,这些不是真正的分支,因为它们永远不会合并回主干,并且它们最好生活在自己的存储库中,其历史将它们链接回“主干”存储库并能够拉取需要时从主干进行更改(当然可以使用 git 轻松完成)。
让事情变得稍微复杂的是,一个客户拥有自己项目的一个分支,这是一个“真正的”分支,因为它将在某个时间点合并回该客户的主分支。
为了让事情变得更清楚,SVN 结构如下:
- “项目”存储库
- 树干
- 分支机构
- 客户端1(从 Trunk v100 分支)
- 客户端2(从 Trunk v150 分支)
- Client2-Branch(从 Client2 v200 分支)
- Client3(从 Trunk v150 分支)
我想要的结构是
"Project " 存储库
Client1 存储库(从 SHA123 分叉)
Client2 存储库(从 SHA456 分叉)
- Client2-Branch(从 SHA456789 分支)
Client3 存储库(从 SHA789 分叉)
任何人都可以推荐一个好方法来执行此操作 -我不是 Git 新手,我知道过滤器分支,我只是不确定应该采取什么方法来获取这个结构并保留尽可能多的历史记录。
谢谢
I have a project in SVN that I'm migrating to Git. The project consists of a "core" product (under trunk), which is then branched within the same repository and used as a starting point to customize for each individual client that we roll the product out to.
It seems to me that these aren't real branches as they will never be merged back into the trunk, and they would be better off living in their own repositories with their history linking them back to the "trunk" repository and the ability to pull in changes from the trunk when required (easily accomplished with git of course).
What makes things slightly more complicated is that one client has a branch of their own project, which is a "real" branch in the sense that it will be merged back onto that clients main branch at some point in time.
To hopefully make things clearer, the SVN structure is as follows:
- "Project" Repository
- Trunk
- Branches
- Client1 (branched from Trunk v100)
- Client2 (branched from Trunk v150)
- Client2-Branch (branched from Client2 v200)
- Client3 (branched from Trunk v150)
And the structure I'd like to get to is
"Project" Repository
Client1 Repository (Forked from SHA123)
Client2 Repository (Forked from SHA456)
- Client2-Branch (branched from SHA456789)
Client3 Repository (Forked from SHA789)
Can anyone recommend a good way to do this - I'm not a Git newbie and I'm aware of filter-branch, I'm just not sure what method I should take to get this structure and keep as much history as possible.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您确实想这样做,请克隆存储库,并删除每个存储库中的无关分支。
但目前的情况似乎还不错。您确定您永远不想从一个存储库挑选补丁到另一个存储库吗?
If you really want to do this, clone the repo, and delete the extraneous branches in each.
But the current situation seems just fine. Are you sure you'll never want to cherry-pick patches from one repo to another?
您可以使用 svn2git 将分支克隆到它们自己的存储库中,就像
您想要创建的每个分支 一样进入分叉仓库,然后
进入主干。
我对一个非常大的 svn->git 转换做了类似的事情。
You can use svn2git to clone the branches into their own repos, something like
for each branch that you want to make into a forked repo, and then
for the trunk.
I did something similar for a very large svn->git conversion.