将代码从自己搭的SVN私服转到Bitbucket私服

原创
2016/09/14 16:49
阅读数 1.4K

自己用VPS搭了个SVN私服,存了以前写的小项目,因为这些代码好久没有动过了,万一哪一天忘记了,代码就丢失了,还是在Bitbucket上存一下好了,反正Bitbucket上面私服免费且不限量。

直接用SVN export会丢失历史check in 记录,查到svn to git migration教程,不是很复杂,记录如下:

参考英文教程:https://www.atlassian.com/git/tutorials/migrating-prepare

1.下载附助工具 svn-migration-scripts.jar 并检查环境

java -jar ~/svn-migration-scripts.jar verify

2.创建1G大小的大小写敏感的文件系统

java -jar ~/svn-migration-scripts.jar create-disk-image 1 GitMigration

3.获取用用户信息数据并转换

cd ~/GitMigration

java -jar ~/svn-migration-scripts.jar authors <svn-repo> > authors.txt

生成authors文件如下:

j.doe = j.doe <j.doe@mycompany.com>

m.smith = m.smith <m.smith@mycompany.com>

改成用户名和邮件形式

j.doe = John Doe <john.doe@atlassian.com>

m.smith = Mary Smith <mary.smith@atlassian.com>

示例如下:

java -jar ~/svn-migration-scripts.jar authors http://www.wuliang.org/svn > authors.txt

ericxu = ericxu <ericxu@mycompany.com>
ghw = ghw <ghw@mycompany.com>
wuliang = wuliang <wuliang@mycompany.com>
zhangyusu = zhangyusu <zhangyusu@mycompany.com>
zhujiaye = zhujiaye <zhujiaye@mycompany.com>
 

4.转化标准SVN目录结构项目(有 trunk,branches,tags标准目录)

git svn clone --stdlayout --authors-file=authors.txt <svn-repo>/<project> <git-repo-name>

示例如下:

git svn clone --stdlayout --authors-file=authors.txt http://www.wuliang.org/svn/rayblog/ rayblog

说明:rayblog下有(trunk,branches,tags目录)

5.转化非标准SVN目录结构项目

git svn clone --trunk=/trunk --branches=/branches --branches=/bugfixes --tags=/tags --authors-file=authors.txt <svn-repo>/<project> <git-repo-name>

示例如下:

git svn clone --trunk=/weather-client --authors-file=authors.txt http://www.wuliang.org/svn/ weather-client

说明:此项目没有trunk,branches,tags目录,项目代码就在http://www.wuliang.org/svn/weather-client 下面。如果命令为 [git svn clone --trunk=/weather-client --authors-file=authors.txt http://www.wuliang.org/svn/weather-client weather-client ] 因路径不对,拿不到代码也不会报错(我第一次便遇到这个问题)

6.目录清理/转换(清理trunk,branches,tags,转换成git的tag)

检查模式,不会正真操作,会告知操作改变,加上(-forece)为真正执行操作

java -Dfile.encoding=utf-8 -jar ~/svn-migration-scripts.jar clean-git

java -Dfile.encoding=utf-8 -jar ~/svn-migration-scripts.jar clean-git --force

7.Git代码上传

cd rayblog

git remote add origin https://wulliam@bitbucket.org/wulliam/rayblog.git

git push -u origin --all

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部