我是靠谱客的博主 激情可乐,这篇文章主要介绍SVN仓库迁移到Git的完美解决办法,现在分享给大家,希望可以做个参考。

参考文章Converting a Subversion repository to Git

1 使用git svn clone 拷贝svn仓库

复制代码
1
2
3
cd ~/test_repo git svn clone file:///home/***/Desktop/SVN/svn_repo/ -T trunk -b branches -t tags

2 新建一个git的bare仓库

复制代码
1
2
3
4
5
cd .. mkdir test.git cd test.git git init --bare

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

复制代码
1
2
git symbolic-ref HEAD refs/heads/trunk

4 将test_repo推送到test.git中

复制代码
1
2
3
4
5
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

复制代码
1
2
3
cd ~/test.git git branch -m trunk master

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

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

复制代码
1
2
3
4
5
6
7
8
9
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

进入工作文件夹,执行

复制代码
1
2
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

最后

以上就是激情可乐最近收集整理的关于SVN仓库迁移到Git的完美解决办法的全部内容,更多相关SVN仓库迁移到Git内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(92)

评论列表共有 0 条评论

立即
投稿
返回
顶部