2012-01-06 111 views
1

我们有远程svn仓库,我们希望它转换为git。 你能告诉我如何在Windows上做到这一点? 谢谢。如何将svn仓库转换为Windows上的git

+1

可能重复的[有没有像TortoiseSVN的git-svn的Windows客户端?](http://stackoverflow.com/questions/894360/is-there-a-git-svn-windows-client-something-like -tortoisesvn),特别是这个答案是适用的:http://stackoverflow.com/a/1090761/19746 – Piskvor 2012-01-06 16:33:11

+0

据我可以判断TortoiseGit只是git客户端,对吧?我问过关于转换svn仓库到git仓库。 – Oleg 2012-01-06 16:35:48

+0

@userwhatever:既然你显然没有点击和/或阅读第二个链接(nb:引用为“特别适用”),让我把它喂给你:“TortoiseGit(http://code.google.com/p/tortoisegit /)在版本0.8.1.0中添加了对git-svn的基本支持“。 *不*适用于什么?请明确点。 – Piskvor 2012-01-06 16:38:11

回答

0

你可以使用git-svn这是一个可以让svn仓库转换为git仓库的工具。请参阅git documentation了解更多信息。

+0

它在Windows上工作吗? – Oleg 2012-01-06 16:37:28

+0

http://stackoverflow.com/a/351321/295756 yup :) – hoppa 2012-01-06 16:38:20

+0

对不起。我无法理解你。你能再解释一下吗? – Oleg 2012-01-06 16:41:26

0

在Windows上安装的应用程序:

找出svn库URL并复制

事情是这样的:
enter image description here

调用TortoiseGit克隆对话框

右击t点击目标文件夹,例如D:\SVN\ToGit,并点击Git Clone...
enter image description here

检查From SVN repository复选框

enter image description here

如果您复制的URL,然后再调用克隆对话框,TortoiseGit将得到剪贴板粘贴复制网址它会放到你的URL文本字段中。所以,你不要自己贴。只要看看它是否正确。

如果您右键单击目标文件夹,TortoiseGit也会为您填写Directory文本字段。另外,请看看是否它是你想要的。

所以,只需检查From SVN repository复选框。

而且如果svn库具有标准布局,说树干,标签,分支,你不需要做其他事情。

单击OK按钮,进入

然后,开始克隆一个SVN仓库到Git仓库。
事情是这样的:

enter image description here

正如你所看到的,只是TortoiseGit正确使用的Git for Windows命令git svn clone克隆它。

git.exe svn clone "svn://svn.code.sf.net/p/tortoisesvn/code/" "D:\SVN\ToGit\tsvn" -T trunk -b branches -t 

所以,基本上,你可以去混帐击/ CMD,并重新使用该命令行,也得到了同样的结果。

注:如果你能看到r1r2r3 ...,你可以随时停止克隆,然后再用相同的命令行恢复它。


克隆一个本地svn库

有了TortoiseGit 2.4.4+

svn的本地路径就复制到克隆对话框的URL。请参阅:
enter image description here
再次,检查From SVN repository复选框

克隆:
enter image description here

TortoiseGit 2.4.4+将使用file:///协议克隆一个本地svn库。


当你得到一个git仓库后,你可以在那里提交。并通过使用TortoiseGit ->SVN DCommit...将提交回到原始svn存储库,类似于svn commit

enter image description here

enter image description here

正如你所看到的,命令是git svn dcommit

如果起源svn库有一些新的承诺(或多个)需要更新,你可以使用TortoiseGit ->SVN Rebase,以获取SVN提交,然后合并/变基上的最新承诺。类似svn update

enter image description here

它采用git svn fetch然后使用git rebase合并/变基所取得的变化。

enter image description here

对于命令行,你可以只使用git svn rebase


阅读Pro Git v2 - Chapter 9了解更多信息和示例。