温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Linux下怎么将SVN迁移至Git

发布时间:2022-01-26 14:37:51 来源:亿速云 阅读:131 作者:zzz 栏目:开发技术

这篇文章主要讲解了“Linux下怎么将SVN迁移至Git”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Linux下怎么将SVN迁移至Git”吧!

1.物理环境

Git–server    Centos5.8    192.168.1.245
Svn–server    Centos5.8    192.168.1.108

2.建立SVN用户到git用户的映射文件

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

cat /tmp/userinfo.txt
david=sfzhang
yanni=yanni

3.克隆一个git版本库

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

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 查看项目提交的历史记录,包括作者,日照,和提交注释信息等。

cd yanzi
git logcommit 3c4907782804096ea3fa3fb5419dcce610e56f1f
Author: david
Date:   Fri May 10 10:27:50 2013 +0000

5.列出当前所有的分支

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

git tag mobile_1.0.0 tags/mobile_1.0.0
git tag mobile_1.0.1 tags/mobile_1.0.1

7.将多余的branches删除掉

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.再次列出当前的所有分支

git branch -r
 trunk
 yanziios1.0.1-build-2223-branch-002

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

mkdir -p /data/gitdata/yanziios.gitcd /data/gitdata/yanziios.git/
git init --bare
Initialized empty Git repository in /data/gitdata/yanziios.git/

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

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服务器上

git push origin master --tags

之后就是SVN迁移到Git测试,在客户端用SourceTree工具克隆一个Git服务端仓库yanziios.git,在SourceTree图形界面里面可以看到git用户提交的Graph信息,描述信息(Description),日期,作者和版本号等信息。

感谢各位的阅读,以上就是“Linux下怎么将SVN迁移至Git”的内容了,经过本文的学习后,相信大家对Linux下怎么将SVN迁移至Git这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI