代码之家  ›  专栏  ›  技术社区  ›  Hackse

将复杂SVN存储库迁移到GIT

  •  1
  • Hackse  · 技术社区  · 10 年前

    我有一个SVN仓库,有100多个项目,我现在想迁移到GIT。SVN存储库的外观如下:

    customer_1/prj_1 (trunk, branches, tags)
    customer_1/prj_2 (trunk, branches, tags)
    customer_1/prj_n (trunk, branches, tags)
    ...
    customer_2/prj_1 (trunk, branches, tags)
    customer_2/prj_2 (trunk, branches, tags)
    customer_2/prj_n (trunk, branches, tags)
    ...
    customer_n/prj_1 (trunk, branches, tags)
    customer_n/prj_2 (trunk, branches, tags)
    customer_n/prj_n (trunk, branches, tags)
    

    通过SVN,我可以结账:

    1. 包含所有客户和所有项目的整个存储库
    2. 单个客户的所有项目
    3. 特定客户的项目

    我仍然需要使用GIT的这三种访问方式,特别是分支和标记单个客户项目,而不仅仅是整个存储库。因此,基本上在SVN中,不同的客户项目都有不同的稳定版本存储在每个项目的“标签”目录中。我还需要区分GIT中的客户项目发布。

    我已经将SVN存储库转换为单个GIT存储库(使用SVN GIT),但由于(我认为)GIT不允许克隆Subversion这样的单个文件夹,所以现在需要使用子模块或子树来构建它。

    是否有必要为每个客户项目创建一个GIT存储库(这需要花费大量时间),或者实现我所要求的最常见的方法是什么?

    1 回复  |  直到 10 年前
        1
  •  0
  •   sleske    10 年前

    如果您需要标记单个客户项目,那么每个项目需要一个git存储库。git中的标记(和分支)对其存储库是全局的,无法标记子目录。

    要执行此操作,请使用 git-svn

    git svn clone -s http://svn-repo/customer_1/prj_1 
    git svn clone -s http://svn-repo/customer_1/prj_2
    

    这可能确实需要一段时间,但你可能不得不忍受。当然,您可以编写对gitsvn的调用脚本。

    关于浏览存储库:

    如果您有多个git repo,您可以将它们作为一个文件夹中的子文件夹签出。如果要在服务器上浏览它们,而不进行克隆/签出,则需要安装git存储库浏览器。有很多可用的-gitwiki中有一个列表: Interfaces, frontends, and tools .