镜像git分支到svn repo

时间:2015-03-26 16:37:58

标签: git svn version-control git-svn bitbucket-server

我正在寻找一种设置现有git存储库的方法(从托管在Atlassian stash上的中央存储库克隆),以便将来自specfic分支的更改同步到SVN存储库上的路径。我对从SVN获取更改或同步分支和标记不是特别感兴趣;我只想拥有一个SVN“镜像”我的一个分支。

在阅读git-svn手册页和其他各种来源后,我得到了使用git svn init设置svn repo,但是它会拒绝提交任何内容:

$ git --version
git version 1.9.5.msysgit.0
$ git clone ssh://git@stash-server.mydomain.com:4321/myproject/playground.git
Cloning into 'playground'...
$ cd playground
$ svn mkdir --parents https://svn-server.mydomain.com:5432/svn/playground/trunk -m "Importing git repo" 
Committed revision 15900.
$ git svn init https://svn-server.mydomain.com:5432/svn/playground/trunk
$ git svn fetch
W: Ignoring error from SVN, path probably does not exist: (175007): HTTP Path Not Found: REPORT request failed on '/svn/145273/!svn/bc/100/playground/trunk': '/svn/145273/!svn/bc/100/playground/trunk' path not found
W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
This may take a while on large repositories
r15900 = 1ad941791edb06c4df8281cd31e69ce5d508e728 (refs/remotes/git-svn)
$ git svn dcommit
Unable to determine upstream SVN information from HEAD history.
Perhaps the repository is empty. at C:\Program Files (x86)\Git/libexec/git-core\git-svn line 856.

“也许存储库是空的” - >当然是,我正在尝试将git分支“克隆”到svn中。知道我在这里做错了吗?

2 个答案:

答案 0 :(得分:5)

您可能需要查看SubGit及其Atlassian Stash的附加组件。转换时,它会巧妙地将Git镜像到SVN。

披露:我为Atlassian工作

答案 1 :(得分:0)

在这里找到答案:http://eikke.com/importing-a-git-tree-into-a-subversion-repository/

  

这失败了,因为git svn命令无法确定要推送哪些提交:我们的原始Git存储库和Subversion头之间没有链接。

     

要解决这个问题,我们可以使用Git移植来链接它们。我们将告诉Git创建我们想要存储项目的SVN文件夹的提交是我们的Git存储库中第一次提交的父提交:

$ git show-ref trunk
741ab63aea786882eafd38dc74369e651f554c9c refs/remotes/trunk
$ git log --pretty=oneline master | tail -n1
88464cfdf549a82b30ee7c52e53e2b310f0d9ec4 Initial version
$ echo "88464cfdf549a82b30ee7c52e53e2b310f0d9ec4 741ab63aea786882eafd38dc74369e651f554c9c" >> .git/info/grafts