用git-svn将git仓库转成一个svn仓库

本文介绍用git-svn将git仓库转成一个svn仓库。要求git本地仓库是线性提交的。

假设我们要将/home/user目录下的git仓库repos.git转成/home/user目录下的svn仓库svn-repos.

1. 首先创建一个空svn仓库

cd /home/user
svnadmin create svn-repos

2. 然后用git-svn将这个空svn仓库转成一个临时的git仓库temp-repos.git
git clone file:///home/user/svn-repos temp-repos.git

3. 将本地git仓库repos.git拉到临时git仓库temp-repos.git
cd temp-repos.git
git remote add repos  /home/user/repos.git
git pull repos

4. 新建两个git分支, 分别指向repos.git的第一个和最后一个提交(等于远程分支repos/master)
git branch start SHA1-of-the-first-revision-of-remote-repository-repos
git branch newmaster repos/master

5. 开始我们的拷贝
git checkout newmaster 
git cherry-pick start
git rebase --onto master start newmaster
此时用git branch查看分支, 应该位于newmaster分支上

6. 提交
git svn dcommit
此时在svn-repos中就是git仓库repos.git中的所有内容了. 此时可以checkout此svn仓库了

7. 测试
cd /home/user/
rm temp-repos.git -rf
svn co file:///home/user/svn-repos work-copy
cd work-copy
svn log
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值