您的位置:首页 > 其它

SVN 迁移到GIT

2014-11-13 18:11 316 查看
为改进开发流程,开发策略改为主干稳定策略,使用svn开发分支与测试分支必须不断切换,为改进切换问题研究git版本管理方法。

基本流程:

1.先用git svn命令把svn文件download到本地

2.git 推送到git版本服务器

1.物理环境

Git-server Redhat 192.168.1.217

Svn-server Redhat 192.168.1.200

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

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。

git svn clone http://192.168.1.217/svn/dummyIdentity/ --no-metadata --authors-file=./userinfo.txt --trunk=trunk/zj_manager_center/police-project-manager --tags=tags --branches=branches --ignore-refs=refs/remotes/police-project-manager-.*  -s police-project-manager

注意:svn路径必须根路径,否则会有问题(路径问题花不少时间),以为参数有问题。

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

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

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

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

参数police-project-manager表示git项目名称

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

cd police-project-manager

git log

commit 3c4907782804096ea3fa3fb5419dcce610e56f1f

Author: david <shifeng_zhang88@163.com>

Date: Fri May 10 10:27:50 2013 +0000

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

cd police-project-manager

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 push命令推送全部的分支和标签信息到git服务器上面。

git push origin master --tags

13.测试

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

参考:
http://stackoverflow.com/questions/12161541/work-around-for-failing-git-svn-clone-requiring-full-history
eclipse插件版本
http://wiki.eclipse.org/EGit/FAQ#Where_can_I_find_older_releases_of_EGit.3F
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: