yum install -y git-svn
如果想保留提交记录,可以用下面的命令找到:
[root@centos3 bbs]# svn log --xml | grep author | sort -u | perl -pe 's/.>(.?)<./$1 = /'
<author>guoxiong</author>
<author>liujiangbu</author>
修改格式:
guoxiong = guoxiong <guoxiong@qq.com>
liujiangbu = liujiangbu <liujiangbu@qq.com>
从svn上clone出要迁移的项目:
[root@centos3 bbs-bak]# git svn clone svn://svn.tttttt.com:9600/bbs/ --no-metadata --authors-file=users.txt^C
[root@centos3 bbs-bak]# ll
total 8
drwxr-xr-x. 14 root root 4096 Aug 29 17:11 bbs
-rw-r--r--. 1 root root 84 Aug 29 17:11 users.txt
[root@centos3 bbs-bak]# cd bbs
[root@centos3 bbs]# git remote add origin git@10.40.2.74:soa/bbs.git
[root@centos3 bbs]# git push origin --all
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
[root@centos3 bbs]# vim .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[svn-remote "svn"]
noMetadata = 1
url = svn://svn.hqygou.com:9600/bbs
fetch = :refs/remotes/git-svn
[svn]
authorsfile = /home/bbs-bak/users.txt
[remote "origin"] #要是没有这两段要加上
url = http://10.40.2.22/soa/bbs.git
然后去gitlab上创建改项目:
[root@centos3 bbs]# git push origin --all
Username for 'http://10.40.2.22': root
Password for 'http://root@10.40.2.74':
Counting objects: 2349, done.
Compressing objects: 100% (2241/2241), done.
Writing objects: 100% (2349/2349), 5.84 MiB | 3.53 MiB/s, done.
Total 2349 (delta 485), reused 0 (delta 0)
remote: Resolving deltas: 100% (485/485), done.
To http://10.40.2.22/soa/bbs.git
* [new branch] master -> master
查看是否迁移成功: