最近在使用华为软件开发云进行开发项目管理,目前华为软件开发云支持500M的免费项目空间,而且还可以在线编译和构建,不用担心开发环境和生产环境的不同,很好的体现了DevOps的开发理念.
之前一直是用svn做代码管理,而华为软件开发云是使用目前国外比较流行的Git进行代码版本控制.在网上查询了迁移方式,发现Git本身有命令可以直接克隆SVN的代码库,而且迁移后能保持原SVN的提交记录.以下是总结的SVN代码库向华为软件开发云迁移的过程.
主要步骤
1.通过git svn clone命令将SVN代码库克隆至本地
2.华为开发云创建代码仓库,获取Git仓库地址
3.本地新建test分支,提交后合并至master分支.开发云代码库中根据引导完成代码合并. (新建分支合并的原因后面会讲.)
准备条件
1.准备要迁移的svn代码库地址;本地安装Git
2.登录华为软件开发云(https://www.hwclouds.com/devcloud/),并已创建好项目.
完整迁移流程
1.通过git svn clone命令将SVN代码库克隆至本地
$ git svn clonehttps://SVN服务器地址/ibeisi.iPMSystem/ --no-metadata --trunk=trunk

#查看SVN提交记录
$ cd ibeisi.iPMSystem/
$ git log

2.华为软件开发云创建代码仓库,获取Git仓库地址
代码仓库创建好之后,需根据在线帮助,添加SSH秘钥,步骤很详细,此处就不作赘述.
SSH秘钥主要是本地与华为软件开发云代码库的一个管理,无需每次通过用户名和密码验证







打开代码仓库,拷贝代码仓库地址

3.根据步骤2中获取到的代码仓库地址,本地添加远程仓库地址
$ git remote add origin
git@codehub.devcloud.hwclouds.com:3bf9c1ed148142d880d759e80100b923/iPMSystem.git
#拉取远程分支
$ git pull
可以看到代码仓库中默认已建好主分支,如果无需保留SVN原提交记录,可以直接将代码通过master分支进行提交(commit)和推送(push);但我想保留原提交记录,所以下面以新建分支合并到master的方式进行代码上传。

4.本地新建分支test,并发起与master分支合并请求
$ git branch test
#checkout命令会让当前切换到test分支,及后续操作都只影响test分支
$ git checkout test

#新建空文件,原因是若没有更改git不会进行push操作
$ vi test.txt
#空文件添加至分支中
$ git add .
#git的commit命令只是在本地提交,并不会上传至代码库.
$ git commit -m "上传代码新建缓存分支"

#通过以下push命令可以发起test与master分支合并请求.
$ git push--set-upstream origin test

5.刷新代码库页面(或重新打开代码库),可以看到合并请求的处理指引,按照指引操作即可完成合并.






可以看到原svn代码库的提交记录都被完整保存了下来.

至此, svn代码库可以说完整地迁移到了华为软件开发云的CodeHub中。
来源:https://www.cnblogs.com/goldenfish/p/6898494.html