首页 > 解决方案 > git svn clone 非标准存储库有问题

问题描述

背景

我正在使用一个巨大的 SVN 存储库(完整克隆约为 20Gb),它具有以下顶级结构:

stuff
stuff/branches
stuff/tags
stuff/trunk
stuff/archive
stuff/build
stuff/machines
stuff/releases

第一点:我不知道 [归档、机器、构建和发布] 目录中包含什么东西,老实说 - 我真的不在乎 - 我只知道我不需要将它们存储在本地来进行开发工作.

第二点:除了用于存储工件的愚蠢目录之外,从表面上看,这似乎是标准的 SVN 布局。但是,当您深入挖掘时,会发现它很奇怪,因为主干目录包含多个项目,例如:

stuff/trunk/mars
stuff/trunk/earth
stuff/trunk/venus
stuff/trunk/saturn
stuff/trunk/pluto
...

分支文件夹的组织方式如下:

stuff/branches/<project>-<name of project branch>

每个分支都是从以下项目之一分支出来的:

stuff/trunk/<project>

我想达到什么目的?

我只想从 pluto 项目(~20Mb)中克隆东西。例如,在 SVN 中执行此操作时,我会发出以下命令:

svn checkout https://svn.example.com/svn/stuff/trunk/pluto
...
Checked out revision 3505

我的问题是我无法使用 git-svn 复制它。我已经多次尝试使用不同的选项来“git svn clone”,每次我最终克隆整个 repo (~20Gb) 或什么都没有。当然它不应该这么困难,所以我一定做错了什么。

如果我能够 git-svn 仅克隆 pluto 项目,当我使用 git-svn 创建一个新分支时,我还希望它为我创建一个 SVN 分支,例如,我希望以下命令是等效的:

svn copy https://svn.example.com/svn/stuff/trunk/pluto \
    https://svn.example.com/svn/stuff/branches/pluto-1234 \
    -m "Making branch pluto-1234 from /stuff/trunk/pluto"

git svn branch -m \
    "Making branch pluto-1234 from /stuff/trunk/pluto" \
    pluto-1234

以便在以下位置创建一个新的 SVN 分支:

stuff/branches/pluto-1234

标签: gitsvnversion-controlgit-svn

解决方案


git svn clone --trunk stuff/trunk/pluto --branches stuff/branches --include-paths='stuff/branches/pluto-.*'

pluto-.*是选择所需分支的正则表达式。见https://git-scm.com/docs/git-svn#Documentation/git-svn.txt---include-pathsltregexgt


推荐阅读