可以从(完整)git-svn克隆重新创建svn存储库吗?

pru*_*wan 8 svn git git-svn

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

编辑:

我可能应该补充一点,我正在寻找一种实用的方法来做到这一点(只要原始的svn存储库仍然可以使用,近乎完美的复制是可以的)

Dmi*_*nko 9

是的,可以创建一个SVN存储库,而不是靠近你的git-svn存储库(甚至可以从Git merge commits和svn:ignore from .gitignore恢复svn:mergeinfo).这样做的步骤:

1.准备分支和标签:

为每个refs/remotes/*创建refs/heads/*(当前refs/heads/*位置将丢失):

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

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

请注意,refs/heads/master映射到SVN中继,但上面的脚本会将refs/heads/trunk设置为refs/remotes/trunk.所以在运行之后应该将refs/heads/master设置为refs/remotes/trunk并删除refs/heads/trunk:

$ git update-ref refs/heads/master refs/remotes/trunk
$ git branch --delete refs/heads/trunk
Run Code Online (Sandbox Code Playgroud)

标签相同:将refs/tags/*设置为refs/remotes/tags/*position:

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

检查所有refs/remotes/*和refs/remotes/tags/*是否转换为refs/heads/*和refs/tags/*,因为只会转换这些引用.

2.创建一个空的SVN存储库

$ svnadmin path/for/svn/repository
Run Code Online (Sandbox Code Playgroud)

3.创建一个包含在步骤1准备的refs/heads/*和refs/tags/*的裸Git存储库:

$ git clone --bare path/to/git-svn/repository path/for/svn/repository/.git
Run Code Online (Sandbox Code Playgroud)

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

$ subgit install path/for/svn/repository
Run Code Online (Sandbox Code Playgroud)

5.在SubGit安装之后,Git和SVN存储库将保持同步.可选择打破双向同步(您可以随时启用它),运行

$ subgit uninstall path/for/svn/repository
Run Code Online (Sandbox Code Playgroud)