将现有git项目提交到svn库

余生长醉 提交于 2019-11-30 23:21:18

原项目使用git管理. 因为各种原因需要提交到svn库.参考资料

  1. 创建svn库
svn co http://svn.example.com/foo
cd myproj
svn mkdir trunk
svn commit -m'Created trunk directory'

或者直接在现有的repository上创建目录

svn mkdir --parents http://url/dir_name --message "messages"
  1. 设置svn远程库

2.1 clone git项目

git clone ~git/repositories/foo/mainline.git ~git/repositories/svn-mirror/foo  
cd ~git/repositories/svn-mirror/foo  

2.2 在.git/config中添加svn-remote

[svn-remote "svn"]
        url = http://svn.example.com/foo/trunk  
        fetch = :refs/remotes/git-svn
  1. 提交项目到svn库

3.1 从空的svn远程库中做初始化fetch,并将其作为一个新分支checkout

git svn fetch svn  
git checkout -b svn git-svn

3.2 将master分支merge进svn分支并提交到svn库
merge时发生 fatal: refusing to merge unrelated histories 错误, 可加 --allow-unrelated-histories

git merge master
git svn dcommit
  1. rebase到svn分支以便从master版本推送到svn库
git checkout master
git rebase svn
git branch -d svn
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!