镜像 git 分支到 svn 仓库

Mirror git branch to svn repo

我正在寻找一种方法来设置现有的 git 存储库(从托管在 Atlassian stash 上的中央存储库克隆),以便将特定分支的更改同步到 SVN 存储库上的路径.我对从 SVN 取回更改或同步分支和标签不是特别感兴趣;我只想拥有我的一个分支机构的 SVN "mirror"。

阅读 git-svn 手册页和其他各种资源后,我了解到使用 git svn init 设置 svn 存储库,但它会拒绝提交任何内容:

$ 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.

"Perhaps the repository is empty" -> 当然是,我正在尝试 "clone" 一个 git 分支到 svn。知道我在这里做错了什么吗?

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

This fails since the git svn command can’t figure out which commits to push: there’s no link between our original Git repository and the Subversion heads.

To fix this, we can use a Git graft to link them. We’ll tell Git the commit which created the SVN folder in which we want to store the project is the parent commit of the first commit in our Git repository:

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

您可能想查看 SubGit 及其用于 Atlassian Stash 的附加组件。在您转换时,它巧妙地负责镜像 Git 到 SVN。

披露:我为 Atlassian 工作