首页 > 解决方案 > 如何将 svn 提交历史或 svn 日志迁移到 gitlab

问题描述

Objective: 将 SVN 日志或 SVN 提交历史迁移到 gitLab。

[请注意:在 Windows 中工作] 通过以下步骤成功将代码从 SVN 迁移到 GIT:

$ mkdir svn-migration
$ cd svn-migration
$ svn co <SVN-URL>

检索 SVN 的作者并存储到文件 author.txt 中。

authors.txt 格式:

Pratim = Pratim <email-id>

遵循以下命令:

    $ git config --global user.name "PratimS"
    $ git config --global user.email "SPratim@company.com"
    $ git config --global svn.authorsfile authors.txt
    $ git svn init <svn-url> --stdlayout
    $ git svn fetch

这样,来自 svn 的主干源代码文件夹将被下载到我的本地目录中。

$ git pull origin master
$ git remote add origin <git-url>
$ git push -u origin master

至此,我已经成功将所有源代码从本地仓库推送到了Gitlab。

有关获取 svn 日志或 svn 中文件的提交历史记录然后将其推送到 Gitlab 的过程的任何建议将非常有帮助。

标签: gitsvngitlabgit-svn

解决方案


我找到了所提出问题的解决方案。

考虑以下命令:

$ mkdir svn-migration
$ cd svn-migration
$ git config --global user.name "PratimS"
$ git config --global user.email "SPratim@company.com"

我们需要 authors.txt 文件包含所有提交 svn 中代码的成员的信息,格式如上述描述中提到的那样

$ git config --global svn.authorsfile authors.txt
$ git svn clone -r<1st revision number of the folder in svn>:HEAD --authors-file=authors.txt <SVN-URL> <Destination-Folder>

此行检索 svn url 中所有文件的所有提交历史并将其存储到目标文件夹中。我们可以通过在 git 克隆的文件夹中执行命令来验证它:

$ git log <any file name>

下一步是将存储在目标文件夹中的文件推送到 Gitlab:

$ git pull origin master

$ git add .

$ git commit . -m "initial commit"

$ git push -u origin master

推荐阅读