打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
SVN数据迁移到Git笔记

SVN数据迁移到Git笔记

2013-06-29 04:56:13     发表评论

由于Git分布式体系结构,用户完全可以脱离Git服务端在本地查看,编辑和提交代码,现在公司Leader要求将SVN上面的数据迁移到Git上面,通过git svn命令可以将SVN里面的数据迁移到Git上面。
1.物理环境
Git-server    Centos5.8    192.168.1.245
Svn-server    Centos5.8    192.168.1.108  

2.建立SVN用户到git用户的映射文件,文件格式如下:

双击代码全选
1
2
3
cat /tmp/userinfo.txt
david=sfzhang<shifeng_zhang88@163.com>
yanni=yanni<yanni_liu88@163.com>

3.通过git svn clone克隆一个git版本库,SVN里面包含trunk,branches和tags。

双击代码全选
1
git svn clone svn://192.168.1.108:9999/yanzi/ --no-metadata --authors-file=userinfo.txt --trunk=trunkmobile --tags=tags --branches=branches --ignore-refs=refs/remotes/yanzi-.*  yanzi

参数--no-metadata表示阻止git导出SVN包含的一些无用信息

   参数--authors-file表示SVN账号映射到git账号文件,所有svn作者都要做映射

   参数--trunkmobile表示主开发项目

   参数--branches表示分支项目,--ignore-refs表示不包含后面的分支项目

   参数yanzi表示git项目名称

4.通过git log 查看项目提交的历史记录,包括作者,日照,和提交注释信息等。

双击代码全选
1
2
3
4
5
cd yanzi
git log
commit 3c4907782804096ea3fa3fb5419dcce610e56f1f
Author: david <shifeng_zhang88@163.com>
Date:   Fri May 10 10:27:50 2013 +0000

5.在git版本库里面tag都是branches(分支),首先列出当前所有的分支。

双击代码全选
1
2
3
4
5
6
cd yanzi
git branch -r
  tags/mobile_1.0.0
  tags/mobile_1.0.1
  trunk
  yanziios1.0.1-build-2223-branch-002

6.手动将branches分支转换为tags。

双击代码全选
1
2
git tag mobile_1.0.0 tags/mobile_1.0.0
git tag mobile_1.0.1 tags/mobile_1.0.1

7.将多余的branches删除掉。

双击代码全选
1
2
3
4
git branch -r -d tags/mobile_1.0.0
Deleted remote branch tags/mobile_1.0.0 (was d50002b).
git branch -r -d tags/mobile_1.0.1
Deleted remote branch tags/mobile_1.0.1 (was e7b78a2).

8.再次列出当前的所有分支。

双击代码全选
1
2
3
git branch -r
  trunk
  yanziios1.0.1-build-2223-branch-002

9.建立git仓库并初始化版本库。

双击代码全选
1
2
3
4
mkdir -p /data/gitdata/yanziios.git
cd /data/gitdata/yanziios.git/
git init --bare
Initialized empty Git repository in /data/gitdata/yanziios.git/

10.将yanziios.git的属主修改为git用户。

双击代码全选
1
2
3
4
5
6
7
8
9
10
11
chown git yanziios.git -R
ls -l yanziios.git/
total 64
drwxr-xr-x 2 git root 4096 May 22 12:25 branches
-rw-r--r-- 1 git root   66 May 22 12:25 config
-rw-r--r-- 1 git root   73 May 22 12:25 description
-rw-r--r-- 1 git root   23 May 22 12:25 HEAD
drwxr-xr-x 2 git root 4096 May 22 12:25 hooks
drwxr-xr-x 2 git root 4096 May 22 12:25 info
drwxr-xr-x 4 git root 4096 May 22 12:25 objects
drwxr-xr-x 4 git root 4096 May 22 12:25 refs

11.添加远程git服务器地址。

git remote add origin git@192.168.1.245:/data/gitdata/yanziios.git

12.用git push命令推送全部的分支和标签信息到git服务器上面。

git push origin --tags

13.SVN迁移到Git测试,在客户端用SourceTree工具克隆一个Git服务端仓库yanziios.git

14.在SourceTree图形界面里面可以看到git用户提交的Graph信息,描述信息(Description),日期,作者和版本号等信息。


 总结:

    1)在运行git svn clone svn: 命令时出现下面的错误:Can't locate SVN/Core.pm in @INC (@INC contains: /usr/local/git/lib/perl5/site_perl/5.8.,需要安装subversion-perl软件包。

    2)在运行git pull git@192.168.1.245:/data/gitdata/yanziios.git时出现下面错误:Can't locate Term/ReadKey.pm in @INC (@INC contains:需要运行下面命令:
Pull up the CPAN teminal:
perl -MCPAN -e shell
Once at the cpan prompt install the needed module:
cpan> install Term::ReadKey

    3)需要在本机用ssh-keygen -t rsa -C your_email_name生成KEY认证文件,然后把公钥id_rsa.pub追加到git服务器的git用户家目录authorized_keys文件里面。

    4)SVN 只有trunk,branches,没有tags导出方法。

git svn clone svn://192.168.1.10:8888/svnproject/ --no-metadata --authors-file=userinfo.txt --trunk=trunk  --branches=branches
--ignore-refs=refs/remotes/yanziios1.* gitproject

    5)git clone 远程分支git clone git@192.168.1.222:/data/gitdata/yanzi/test.git --branch  test-build-1442-branch-001 test-001

    6)更多的错误详见http://blog.csdn.net/jingwenlai_scut/article/details/4771348

本文出自 “朴实的追梦者” 博客,请务必保留此出处http://sfzhang88.blog.51cto.com/4995876/1198867

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Git 常用命令详解(二)
如何让公司从SVN改到Git?
SVN和Git的比较
常用SVN目录结构简明介绍 - 51CTO.COM
项目版本控制
git获取linux内核源码及分支管理
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服