设为首页 收藏本站
查看: 1070|回复: 0

[经验分享] 使用subgit进行svn迁移至git(branch,tags)

[复制链接]

尚未签到

发表于 2018-1-12 14:02:00 | 显示全部楼层 |阅读模式
  前言:
  最近公司需要将整体项目从svn迁移至gitlab上,经过几天的研究,现记录一下流程
  整体思路是进行一次导入:
  先通过subgit将svn整个import至本地,在与git上的项目进行合并.
  1.硬件环境
  git:git version 2.7.4
  svn: 1.6.11
  subgit:3.2.2
  2.下载subgit
  官网下载subgit: https://subgit.com/
  将subgit解压:    
  

tar -zcvf subgit-3.2.2.zip   

  3.在gitlab上新建一个需要合并的项目
  进入gitlab管理界面,新建项目:lclctest  
  

git@xx.xx.xx.xx:lclc/lclctest.git (我这边新建了一个lclc的组)  

  建好以备用.
  4.进入subgit-3.2.2/bin 目录,使用configure命令  
  

./subgit configure http://ip:port/svn/lclctest  lclctest  

  完成后会有一些提示:  
  

1) Adjust Subversion to Git branches mapping if necessary:/root/lclctmp/tmp/subgit-3.2.2/bin/lclctest/subgit/config  

2) Define at least one Subversion credentials in default SubGit passwd file at:/root/lclctmp/tmp/subgit-3.2.2/bin/lclctest/subgit/passwd  OR configure SSH
or SSL credentials in the [auth] section of:/root/lclctmp/tmp/subgit-3.2.2/bin/lclctest/subgit/config  

3) Optionally, add custom authors mapping to the authors.txt file(s) at:/root/lclctmp/tmp/subgit-3.2.2/bin/lclctest/subgit/authors.txt  

4) Run SubGit 'install' command:  subgit install lclctest
  

  意思是进行一些配置,然后进行install
  配置config:由于3.2.2默认是配置好的,可以不进行配置  
  

trunk = trunk:refs/heads/master  
branches
= branches/*:refs/heads/*  
branches
= branches/features/*:refs/heads/features/*  
branches
= hotfixes/*:refs/heads/hotfixes/*  
tags
= tags/*:refs/tags/*  
shelves
= shelves/*:refs/shelves/*  

  配置用户映射文件 author.txt 格式为:svnUser = Git User <user@example.com> (也可以不修改)
  5.进行install
  

$ ./subgit install lclctest  

  此步将连接svn,需要耗时一段时间.
  完成后就把svn代码迁移到本地库了,这时候就需要用git push到远程库中
  6.clone版本  
  

git clone ./lclctest lclctest.git  

  7.进入lclctest.git目录  
  

git remote set-url origin git@yourip:lclc/lclctest.git(之前创建的git项目)  

  

git push origin master  

  在push的时候发现提示填写密码:  
  

 git@ip's password:  

  此时说明需要进行身份验证,我们给git添加一个keygen就行了
  7.1:生成keygen 
  

cd ~  
ssh
-keygen -t rsa -C "your_email@example.com"  


  生成的文件在 .ssh文件下有>  7.2:上传keygen
  打开gitlab的管理界面

  将id_rsa.pub文件中的内容复制到Key的文本框里.
  再执行步骤7的git push origin master命令上传master
  8.上传分支.
  进入lclctest.git目录,使用命令查看分支  
  

git branch -a  

  结果:
  

* master  remotes
/origin/HEAD -> origin/master  remotes
/origin/bugfix  remotes
/origin/develop  remotes
/origin/feature  remotes
/origin/master  

  本项目一共有3个分支,分别是bugfix,develop,feature,分别进行上传
  

git push origin remotes/origin/feature:refs/heads/feature  

git push origin remotes/origin/bugfix:refs/heads/bugfix  

git push origin remotes/origin/develop:refs/heads/develop  

  注意:冒号后面为远程库中的地址,必须以refs/heads开头.
  9.上传tags
  

git push --tags  

  参考资料:
  http://lattecake.com/post/20051
  http://stackoverflow.com/questions/23251394/subgit-import-and-multiple-branches-directories

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-434263-1-1.html 上篇帖子: Git Lab UserGuide 下篇帖子: Git使用ssh key
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表