如何获取SVN仓库的本地副本?

3
我正在尝试将我的 SVN 仓库迁移到 Git。为了实现这一点,我必须在本地机器上拥有我的 SVN 仓库。到目前为止,我尝试过 svn checkout、git svn clone、svndump,但都没有成功。我找到了 rsync,但是它也会出现错误,而我无法摆脱它。
我在要复制仓库的目录中执行以下命令:
rsync -a . username@domain.host:http://someAddress/svn/repoName 然后出现以下错误:
ssh: Could not resolve domain.host: Name or service not known rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(605) [sender=3.0.9]
请问是否能够给出此场景的简单用例示例?
谢谢您的帮助。
更新:我尝试了以下操作:
svnadmin dump http://someAddress/svn/Reponame > Reponame-svn.out

并且遇到了以下错误:
svnadmin: 'http://someAddress/svn/Reponame' is an URL when it should be a path

所以,这也不起作用。。
3个回答

4
如果您无法直接访问Subversion服务器并且正在使用最新的客户端(应该是这样),则可以使用svnrdump创建一个转储文件,然后将其加载到本地存储库中,在那个时间点上制作完整存储库的副本,然后将其转换为git。
如果您可以直接访问服务器,请在服务器上使用svnadmin dump创建相同的转储文件,然后将其传输到您正在工作的位置,加载到新存储库中,并运行转换。

我不在服务器机器上,因此我需要一些东西可以在自己的机器上执行(前提是从服务器获得授权凭据),并获取存储库的副本,以便我可以将其迁移到Git存储库。 - user4964330
另外,出现了“svnrdump:命令未找到”的问题,我正在使用1.6.17版本。 - user4964330
如果您无法访问服务器,则“svnrdump”是您的解决方案(假设您对存储库中所需的每个路径都具有读取访问权限)。您需要升级客户端 - 您已经过时了七年 - alroc
很遗憾,这不在我的能力范围内。我被要求将此存储库迁移到Git存储库,并且我正在拼命寻找方法来完成它。到目前为止,我尝试过的所有方法都失败了。似乎svnrdump也被添加到列表中了... - user4964330
1
你甚至无法将新版本的客户端安装到用户目录中吗?如果您没有运行 svnrdump 的能力,也没有访问服务器的权限,那么您被分配的任务(迁移存储库历史记录)几乎是不可能完成的。剩下的唯一选择是检出存储库的每个修订版本,并按顺序将它们提交到一个新的git存储库中。 - alroc

1
注意,一旦您复制了svndump/svnadmin dump的结果(如接受的答案中建议的),可以使用svn2gitsubgit将其导入到Git存储库中。过去(2009-2012年),曾经进行了一个vcs-svn实验,将SVN“dumpfile”转换为Git快速导入流,但是...随着Git 2.29(2020年第4季度)的推出,这个实验已经被彻底取消了。

请查看由Jeff King (peff)于2020年8月13日提交的fc47391次提交, a006f87次提交, d7a5649次提交, b5dd96b次提交, a04f653次提交
(合并自Junio C Hamano -- gitster --在2020年9月3日提交的afd49c3次提交)

svn:放弃 VCS-SVN 实验

Signed-off-by: Jeff King

The code in vcs-svn was started in 2010 as an attempt to build a remote-helper for interacting with svn repositories (as opposed to git-svn).
However, we never got as far as shipping a mature remote helper, and the last substantive commit was [e99d012a6bc](https://github.com/git/git/commit/e99d012a6bc8b8647a0389d486b5489557364ea6, Git v1.8.1-rc0) in Oct. 2012.

We do have a git-remote-testsvn, and it is even installed as part of "make install". But given the name, it seems unlikely to be used by anybody (you'd have to explicitly "git clone testsvn::$url(man), and there have been zero mentions of that on the mailing list since 2013, and even that includes the phrase "you might need to hack a bit to get it working properly").

We also ship contrib/svn-fe, which builds on the vcs-svn work.
However, it does not seem to build out of the box for me, as the link step misses some required libraries for using libgit.a.
Curiously, the original build breakage bisects for me to eff80a9fd9 (Allow custom "comment char", 2013-01-16, Git v1.8.2-rc0), which seems unrelated.
There was an attempt to fix it in da011cb0e7 ("contrib/svn-fe: fix Makefile", 2014-08-28, Git v2.2.0-rc0 -- merge), but on my system that only switches the error message.

So it seems like the result is not really usable by anybody in practice.
It would be wonderful if somebody wanted to pick up the topic again, and potentially it's worth carrying around for that reason. But the flip side is that people doing tree-wide operations have to deal with this code.
And you can see the list with (replace "HEAD" with this commit as appropriate):

{
  echo "--"
  git diff-tree --diff-filter=D -r --name-only HEAD^ HEAD
} |
git log --no-merges --oneline e99d012a6bc.. --stdin  

which shows 58 times somebody had to deal with the code, generally due to a compile or test failure, or a tree-wide style fix or API change.

Let's drop it and let anybody who wants to pick it up do so by resurrecting it from the Git history.

As a bonus, this also reduces the size of a stripped installation of Git from 21MB to 19MB.


0

rsync 只能在 SSH 连接下工作,而不能在 HTTPS 下工作。此外,它还要求您可以访问服务器的控制台(即您的仓库托管在 Linux/Unix 服务器上)。因此,除非您拥有用于托管 SVN 仓库的服务器的 SSH 密钥,这将使您处于 $# 提示符下,否则您将无法使用 rsync(或 scp)获取仓库文件。

如果是 Windows 服务器,则需要 RDP 访问权限(或某种方式运行命令,然后将文件放在您可以下载的地方)。

要备份 SVN 仓库目录,svndumpsvnadmin hotcopy 都可以使用。两者都必须在服务器上的命令行中执行。然后,您需要将转储文件(svndump)或由 svnadmin hotcopy 创建的仓库目录传输到本地计算机。


两台机器都使用Linux平台。然而我的机器不是服务器,我只是恰好有远程访问权限。我应该使用什么来复制存储库,以便我可以将其迁移到Git? - user4964330

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接