简体   繁体   English

git svn - 所有外部的克隆回购

[英]git svn - clone repo with all externals

I want to use git to clone a svn repository, but unfortunately, where svn checkout gets the repo with all externals, git svn clone only gets the repository without externals. 我想使用git来克隆svn存储库,但不幸的是,在svn checkout获取所有外部的repo时, git svn clone只获取没有externals的存储库。 How can I get the externals from the svn repository via git svn ? 如何通过git svn从svn存储库获取外部代码? I don't want to do any fancy stuff, just get the the complet repo with externals. 我不想做任何花哨的东西,只需要获得外部的complet repo。

git-svn doesn't support externals, but you may try SmartGit instead of git-svn. git-svn不支持外部,但您可以尝试使用SmartGit而不是git-svn。 It supports svn:externals, converting them into .gitsvnextmodules file and displaying as modules. 它支持svn:externals,将它们转换为.gitsvnextmodules文件并显示为模块。 The only restriction: you should clone the repository with SmartGit instead of opening already existing git-svn repository. 唯一的限制:您应该使用SmartGit克隆存储库,而不是打开现有的git-svn存储库。

I have been use git as a front end to access a SVN repository. 我一直使用git作为访问SVN存储库的前端。 The structure in SVN is generally pretty simple such that there is top level directory which has the externals in it and no externals in sub-directories. SVN中的结构通常非常简单,因此存在顶级目录,其中包含外部,而子目录中没有外部。 Also the externals don't really change much once they are added in. So assuming something like: 一旦添加它们,外部实际上并没有太大变化。所以假设如下:

git svn clone X
cd X

I have had success getting all the externals with the following command: 我使用以下命令获得了所有外部成功:

git svn show-externals | \
 perl -ne 'if (/^\/(.*) (.*)/) { print "git svn clone $1 $2\n"; }' | \
 bash

I guess a more complicated structure for externals would require a more complicated perl script. 我猜一个更复杂的外部结构需要更复杂的perl脚本。 Also, if your externals change you will need to do something similar again. 此外,如果您的外部变化,您将需要再次做类似的事情。

I post solution here that works in my case 我在这里发布的解决方案适合我的情况

git svn show-externals | \
  awk '/^\// { print "git svn clone "$3" ."$1" "$2":HEAD"  }' | \
  bash

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

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