可以从(完整)git-svn克隆重新创建svn存储库? [英] possible to recreate svn repository from (full) git-svn clone?

查看:111
本文介绍了可以从(完整)git-svn克隆重新创建svn存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为标题,有没有什么办法从git-svn(包含从r1开始的每个单独提交)重新构建完整克隆的svn repo?



编辑:

我应该补充一点,我正在寻找一种切实可行的方法来做到这一点(只要它仍然可用,就像原始的svn仓库一样,近乎完美的复制是可以的)

解决方案

是的,可以创建一个SVN仓库,而不是靠近你的git-svn仓库(甚至可以从Git恢复svn:mergeinfo合并提交和svn:从.gitignore忽略)。步骤如下:

1.准备分支和标签:

创建refs / heads / * for每一个refs / remotes / *(current refs / heads / *职位将会丢失):

  $ git branch -a | awk'/ remotes \ /([^ \ /])+ $ / {ref = substr($ 1,9);系统(git update-ref refs / heads /refrefs / remotes /ref)}'

或者你可以为所有感兴趣的分支手动设置refs / heads / *

注意refs / heads / master映射到SVN trunk,但是上面的脚本会设置refs /头/后备箱/裁判/后备箱。所以在运行之后,应该将refs / heads / master设置为refs / remotes / trunk并删除refs / heads / trunk:

  $ git update-ref refs / heads / master refs / remotes / trunk 
$ git branch --delete refs / heads / trunk

同样的标签:set refs / tags / *到refs / remotes / tags / * positions:

  $ git branch -a | awk'/ remotes \ / tags\ /([^ \ /])+ $ / {ref = substr($ 1,14);系统(git update-ref refs / tags /refrefs / remotes / tags /ref)}'

检查所有refs / remotes / *和refs / remotes / tags / *转换为refs / heads / *和refs / tags / *,因为只有这些引用将被转换。



2.创建一个空的SVN库

  $ svnadmin path / for / svn / repository 



<3>创建一个包含refs / heads / *和refs / tags / *的裸Git仓库,

  $ git clone --bare path / to / git-svn / repository path / for / svn / repository / .git 

4.使用链接(中间构建,从Git中删除git-svn-id:签名在转换时提交消息)。一般来说,SubGit不是免费的,但对于一次性转换(您的情况),它可以免费使用。使用SubGit转换存储库(它希望在path / for / svn / repository / .git中找到Git存储库)

  $ subgit安装路径/ for / svn / repository 

5.安装完SubGit后,Git和SVN版本库会保留同步中。或者打破双向同步(你可以随时启用它),运行

  $ subgit uninstall path / for / svn /存储库


As title, is there any way to reconstruct a svn repo from a full clone with git-svn (containing every single commit starting from r1)?

Edit:

I probably should add that I am looking for a practical means to do it (near-perfect copy is okay as long as it remains usable just as the original svn repository)

解决方案

Yes, it's possible to create an SVN repository rather close to your git-svn repository (even restoring svn:mergeinfo from Git merge commits and svn:ignore from .gitignore). The steps to do that:

1.Prepare branches and tags:

Create refs/heads/* for every refs/remotes/* (current refs/heads/* positions will be lost):

$ git branch -a | awk '/remotes\/([^\/])+$/{ref=substr($1, 9); system("git update-ref refs/heads/" ref " refs/remotes/" ref )}'

or you can set refs/heads/* for all interesting branches manually

Note that refs/heads/master is mapped to SVN trunk but the script above will set refs/heads/trunk to refs/remotes/trunk. So after running it one should set refs/heads/master to refs/remotes/trunk and delete refs/heads/trunk:

$ git update-ref refs/heads/master refs/remotes/trunk
$ git branch --delete refs/heads/trunk

The same about tags: set refs/tags/* to refs/remotes/tags/* positions:

$ git branch -a | awk '/remotes\/tags\/([^\/])+$/{ref=substr($1, 14); system("git update-ref refs/tags/" ref " refs/remotes/tags/" ref )}'

Check that all refs/remotes/* and refs/remotes/tags/* are converted to refs/heads/* and refs/tags/* because only these references will be converted.

2.Create an empty SVN repository

$ svnadmin path/for/svn/repository

3.Create a bare Git repository containing refs/heads/* and refs/tags/* prepared at step 1:

$ git clone --bare path/to/git-svn/repository path/for/svn/repository/.git

4.Download and install SubGit using this link (intermediate build that removes "git-svn-id:" signatures from Git commits messages while converting). In general, SubGit is not free but for one shot conversion (your case) it can be used for free. Convert the repository with SubGit (it expects to find the Git repository at path/for/svn/repository/.git)

$ subgit install path/for/svn/repository

5.After SubGit installation Git and SVN repositories will be kept in sync. Optionally to break bi-directional synchronization (you can enable it any time), run

$ subgit uninstall path/for/svn/repository

这篇关于可以从(完整)git-svn克隆重新创建svn存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆