SVN仓库迁移到Git遇到的两个问题和解决办法

OS: CentOS 7.0

准备: git svn git-svn

sudo yum install git
sudo yum install subversion
sudo yum install git-svn

版本:

subversion x86_64 1.7.14-10.el7
git-svn x86_64 1.8.3.1-6.el7_2.1

问题一

perl: subversion/libsvn_subr/dirent_uri.c:321: canonicalize: Assertion `*src != '/'' failed.
error: git-svn died of signal 6

原因是我使用的本地仓库,在写url的时候格式不对,正确的写法如下:

git svn clone file:///home/***/Desktop/SVN/test_repo/

本地仓库需要加上file://前缀

问题二

Initialized empty Git repository in /home/****/.git/
Couldn't open a repository: Unable to connect to a repository at URL 'file:///home/***': Unable to open an ra_local session to URL: Unable to open repository 'file:///home/***': Expected FS format between '1' and '4'; found format '6' at /usr/share/perl5/vendor_perl/Git/SVN.pm line 310.

这个错误是由于建立版本库的时候使用的svn版本较高,建立了FS格式为6的版本库,在低版本的svn客户端下不能识别。
解决办法为:
进入待迁移的版本库中,进入db文件夹,修改format文件

vim format

  1 6
  2 layout sharded 1000                           

将6改为4就可以了。

P.S. 将得到的本地Git repo 上传到remote repo

将本地repo中的branch存为Git的tag。

#查看branches
git branch -r

#将branch转为tag
git tag tag_name existed_branch_name

#将tags推送到remote repo
git push origin master --tags

#查看repo中tags的命令为
git tag
#或
git tag -l

#获取指定的tag
git checkout tag_name

#转换到指定的tag上工作,并为该tag新建branch
git checkout -b branch_name tag_name

转载请联系chasenwu@live.com

原文地址:https://www.cnblogs.com/shawnpoo/p/SVN-cang-ku-qian-yi-daoGit-yu-dao-de-liang-ge-wen-.html