将现有git项目提交到svn库

原项目使用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

转载于:https://my.oschina.net/CasparLi/blog/717759

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值