如何使用git-svn只检查主干而不是分支和标签?

时间:2013-01-29 14:52:46

标签: git svn git-svn

我正在开发一个Java遗留项目,该项目有20个模块相互连接。因此,每个模块都有自己的分支和标记。结构是这样的:


/projects
   .svn
   - module1
       .svn
       -trunk
       -branch
       -tag
   - module2
       .svn
       -trunk
       -branch
       -tag

projects文件夹大约是30 GB,几乎不可能使用git-svn clone签出所有模块,但这是因为它计算了所有分支和标签。

是否可以只修复项目中继,以便我可以开始在本地提交?

3 个答案:

答案 0 :(得分:56)

编辑:我误解了这个问题并回答了我的想法,而不是你实际问过的问题。

仅克隆主干

克隆单个Subversion目录很简单,实际上克隆哪个目录无关紧要。只是不要指定任何“layout”参数,并直接给出trunk的路径:

git svn clone http://path.to.svn.repo/module1/trunk

克隆特定模块,包括标签和分支等

“正常”git svn clone类似于以下内容:

git svn clone --stdlayout http://path.to.svn.repo/

您想要使用的是:

git svn clone --stdlayout http://path.to.svn.repo/module1/

这会找到trunk文件夹的branchtagmodule1子文件夹,并为您克隆它们。

答案 1 :(得分:13)

我发现使用--stdlayout的git svn clone对我来说做得不对。

在同样的情况下,这种策略运作良好:

git svn init --trunk $repo/projects/module1/trunk --tags $repo/projects/module1/tag --branches $repo/projects/module1/branch
git svn fetch

答案 2 :(得分:3)

我只想根据@me_and的答案添加更多信息。

克隆只是trunk的命令会起作用,但在git文件夹中创建的结构是:

refs
 |--remotes
    |--git-svn

相当于 refs / remotes / git-svn

如果我们这样做:

git svn clone https://domain/svn/repo/trunk --no-metadata --authors-file=authors.txt --trunk=https://domain/svn/repo/trunk

然后创建的结构是:

refs
 |--remotes
    |--origin
       |--trunk

相当于 refs / remotes / origin / trunk

第二个结构看起来更友好,可能会减少你必须写的命令和shell脚本:)

P.S。 [--no-metadata]和[--author-file]参数是可选的。

  • 元数据选项禁止git在提交消息后追加svn信息。
  • authors-file选项允许您将svn贡献者映射到git贡献者,这样你的svn历史修订版就不会在git中搞砸了。