侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

svn 迁移到git

2023-12-09 星期六 / 0 评论 / 0 点赞 / 99 阅读 / 3594 字

1.物理环境 Git–server Centos5.8 192.168.1.245Svn–server Centos5.8 192.168.1.108 2.建立SVN用户到gi

1.物理环境

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

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

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

cat /tmp/userinfo.txtdavid=sfzhangyanni=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 yanzigit logcommit 3c4907782804096ea3fa3fb5419dcce610e56f1fAuthor: david Date:   Fri May 10 10:27:50 2013 +0000

5.列出当前所有的分支

cd yanzigit 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.0git tag mobile_1.0.1 tags/mobile_1.0.1

7.将多余的branches删除掉

git branch -r -d tags/mobile_1.0.0Deleted remote branch tags/mobile_1.0.0 (was d50002b).git branch -r -d tags/mobile_1.0.1Deleted 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 --bareInitialized empty Git repository in /data/gitdata/yanziios.git/

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

chown git yanziios.git -Rls -l yanziios.git/total 64drwxr-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 HEADdrwxr-xr-x 2 git root 4096 May 22 12:25 hooksdrwxr-xr-x 2 git root 4096 May 22 12:25 infodrwxr-xr-x 4 git root 4096 May 22 12:25 objectsdrwxr-xr-x 4 git root 4096 May 22 12:25 refs

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

git remote add origin [email protected]:/data/gitdata/yanziios.git

12.推送全部的分支和标签信息到git服务器上

git push origin master --tags

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

  相关知识链接:http://www.linuxprobe.com/chapter-21/
.

免费提供最新Linux技术教程书籍,为开源技术爱好者努力做得更多更好:http://www.linuxprobe.com/

.

广告 广告

评论区