将一个 Git 存储库拆分为多个 - 分支成为分支

发布于 2024-09-28 11:18:21 字数 848 浏览 3 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仅此而已 2024-10-05 11:18:21

如果您确实想这样做,请克隆存储库,并删除每个存储库中的无关分支。

但目前的情况似乎还不错。您确定您永远不想从一个存储库挑选补丁到另一个存储库吗?

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?

苏璃陌 2024-10-05 11:18:21

您可以使用 svn2git 将分支克隆到它们自己的存储库中,就像

svn2git svn://project/branches/client1 --rootistrunk

您想要创建的每个分支 一样进入分叉仓库,然后

svn2git svn://project/trunk --rootistrunk

进入主干。

我对一个非常大的 svn->git 转换做了类似的事情。

You can use svn2git to clone the branches into their own repos, something like

svn2git svn://project/branches/client1 --rootistrunk

for each branch that you want to make into a forked repo, and then

svn2git svn://project/trunk --rootistrunk

for the trunk.

I did something similar for a very large svn->git conversion.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文