2022
我们一起努力

svn 迁移到git具体方法

本篇文章重点为大家讲解一下svn迁移到git具体方法, 有需要的小伙伴可以参考一下。

image-20220726214657138

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 log
commit 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.git
cd /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),日期,作者和版本号等信息。

本文来源:www.lxlinux.net/10096.html,若引用不当,请联系修改。

赞(0)
文章名称:《svn 迁移到git具体方法》
文章链接:https://www.fzvps.com/180906.html
本站文章来源于互联网,如有侵权,请联系管理删除,本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
图片版权归属各自创作者所有,图片水印出于防止被无耻之徒盗取劳动成果的目的。

评论 抢沙发

评论前必须登录!