SVN仓库迁移到Git的完美解决办法

参考文章Converting a Subversion repository to Git

1 使用git svn clone 拷贝svn仓库

cd ~/test_repo
git svn clone file:///home/***/Desktop/SVN/svn_repo/ -T trunk -b branches -t tags

2 新建一个git的bare仓库

cd ..
mkdir test.git
cd test.git
git init --bare

3 将git的默认分支和svn的默认分支trunk对应起来

git symbolic-ref HEAD refs/heads/trunk

4 将test_repo推送到test.git中

cd ~/test_repo
git remote add bare ~/test.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare

此时就完成了推送,可以删除test_repo了

5 将git repo中的trunk重命名为master

cd ~/test.git
git branch -m trunk master

6 将svn repo中的tags移动到git repo的相应位置

使用git svn clone导出版本库的时候会将svn中的tags保存成git中的tags/**,而并不是默认的tag,所以要进行移动

cd ~/test.git
git for-each-ref --format='%(refname)' refs/heads/tags |
cut -d / -f 4 |
while read ref
do
  git tag "$ref" "refs/heads/tags/$ref";
  git branch -D "tags/$ref";
done

7 完成迁移,得到test.git

进入工作文件夹,执行

git clone ~/test.git

使用git进行版本管理吧


转载请联系chasenwu@live.com

转载于:https://www.cnblogs.com/shawnpoo/p/SVN-cang-ku-qian-yi-daoGit-de-wan-mei-jie-jue-ban-.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值