繁体   English   中英

使用Git-Svn克隆非标准Svn存储库

[英]Cloning a Non-Standard Svn Repository with Git-Svn

我对Git比较陌生,但我发现在家工作很容易,我想在我们的项目存储在Svn存储库中的工作中使用它。 不幸的是,存储库略微不标准,我无法克隆它们。 当然,它们都有trunk,branches /和tags /,但是在命中实际项目目录之前,branch /和tags /都有子目录:

trunk/
branches/maintenance/release1
branches/maintenance/release2
...
branches/development/feature1
branches/development/feature2
...
tags/build/build1
tags/build/build2
...
tags/release/release1
tags/release/release2

克隆后:

$ git svn clone -s --prefix=svn/ https://mydomain.com/svnproject
$ git branch -r
  development
  development@1340
  maintenance
  maintenance@1340
  tags/build
  tags/build@1340
  tags/release
  tags/release@1340
  trunk
  trunk@1340 

我没有得到任何实际的项目分支或标签。 我实际上需要能够在主干,一个维护分支和一个开发分支上工作。 我已经尝试过这种方法,除了修改配置的几个黑客,但没有什么对我有用。

有什么方法可以将我的非标准Svn项目的关键组件放到本地git存储库中,以便我可以轻松地在它们之间移动?

非常感谢。

更新:我应该补充一点,我不能批量切换到Git(尚)。 还有其他团队成员参与和国际存在。 转型的后勤工作比我更愿意承担,直到我对Git更加满意; 正如我所提到的,我还是很新的。 我几乎没有触及其功能的表面。

李B是对的。 doener在#git中提供的答案是将Git升级到1.6.x(我一直在使用1.5.x)。 1.6.x提供了深度克隆,因此可以使用--branches选项使用多个通配符:

$ git svn clone https://svn.myrepos.com/myproject web-self-serve \ 
          --trunk=trunk --branches=branches/*/* --prefix=svn/
$ git branch -r
  svn/development/sandbox1
  svn/development/feature1
  svn/development/sandbox2
  svn/development/sandbox3
  svn/development/model-associations
  svn/maintenance/version1.0.0
  svn/trunk

正是我需要的。 感谢所有人的洞察力。

您可以尝试nirvdrum的svn2git (似乎是最新的),以便将您的svn导入git存储库吗?
(2009年初, Paul提到了这个iteman的svn2git来代替这个原始的jcoglan的svn2git ,就像他的作者提到的那样:“快速破解我的代码脱离Subversion”)

它比git svn clone更好,因为如果你在svn中有这个代码:

  trunk
    ...
  branches
    1.x
    2.x
  tags
    1.0.0
    1.0.1
    1.0.2
    1.1.0
    2.0.0

git-svn将通过提交历史记录来构建一个新的git repo。
它将所有分支和标签导入为远程svn分支,而你真正想要的是git-native本地分支和git标记对象
因此,在导入此项目后,您将获得:

  $ git branch
  * master
  $ git branch -a
  * master
    1.x
    2.x
    tags/1.0.0
    tags/1.0.1
    tags/1.0.2
    tags/1.1.0
    tags/2.0.0
    trunk
  $ git tag -l
  [ empty ]

在你的项目完成svn2git后,你会得到这个:

  $ git branch
  * master
    1.x
    2.x
  $ git tag -l
    1.0.0
    1.0.1
    1.0.2
    1.1.0
    2.0.0

当然,这个解决方案并不是单程旅行。

您可以随时返回到您的svn存储库,使用... git2svn (也存在于那里

这个想法依旧:

  • SVN作为中央存储库工作。

  • Git“在其他地方”快速在多个Git私有分支机构中进行实验。

  • 导入合并的Git分支到官方SVN分支。

对于普通通配符不提供的回购布局:(来自 对此相关问题的回答

当前的git-svn联机帮助页说:

也可以通过在大括号内使用逗号分隔的名称列表来获取分支或标记的子集。 例如:

[svn-remote "huge-project"]
     url = http://server.org/svn
     fetch = trunk/src:refs/remotes/trunk
     branches = branches/{red,green}/src:refs/remotes/branches/*
     tags = tags/{1.0,2.0}/src:refs/remotes/tags/*

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM