【问题标题】:How do I migrate an SVN repository with custom structure to Git?如何将具有自定义结构的 SVN 存储库迁移到 Git?
【发布时间】:2018-05-15 11:03:54
【问题描述】:

我在 SVN 中有一个多模块遗留项目,其中各个模块分别发布和标记,从而产生以下结构:

trunk/
  project/
    moduleX/
    moduleY/
    moduleZ/
tags/
  moduleX-1.0/
  moduleX-1.1/
  moduleY-0.1/
  moduleZ-2.0/

看起来标签是用svn copy trunk/project/moduleX/ tags/moduleX-1.0/等创建的,而不是svn copy trunk/project/ tags/moduleX-1.0

是否可以将此类项目作为单个存储库迁移到 Git,保留历史记录并创建适当的标签?

【问题讨论】:

    标签: git-svn


    【解决方案1】:

    需要手动配置git-svn。

    1. 创建空存储库:git init moduleX ; git init moduleY ; git init moduleZ
    2. 编辑每个 gitconfig 并添加一个 git-svn 部分,如:

    moduleX/.git/config:

    [svn-remote "svn"]
        url = svn://your-server/svn-repo
        fetch = trunk/project/moduleX:refs/remotes/svn/trunk
        tags = tags/moduleX-*:refs/remotes/svn/tags/*
    

    moduleY/.git/config:

    [svn-remote "svn"]
        url = svn://your-server/svn-repo
        fetch = trunk/project/moduleY:refs/remotes/svn/trunk
        tags = tags/moduleY-*:refs/remotes/svn/tags/*
    

    moduleZ/.git/config:

    [svn-remote "svn"]
        url = svn://your-server/svn-repo
        fetch = trunk/project/moduleZ:refs/remotes/svn/trunk
        tags = tags/moduleZ-*:refs/remotes/svn/tags/*
    
    1. git svn fetch 在每个副本中。

    【讨论】:

    • 好的,但这不会给我三个独立的存储库而不是单个多模块一个吗?或者以后有没有办法把它们结合起来?
    • 糟糕,对不起!错过了single repository 部分。但是,在那种情况下,什么会阻止你使用普通的git svn clone -s
    • 因为每个标签只包含与特定模块相关的子目录,而不是整个结构(我更新了问题)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-23
    • 1970-01-01
    • 1970-01-01
    • 2020-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多