Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将git存储库克隆到subversion存储库的子目录中_Git_Git Svn - Fatal编程技术网

将git存储库克隆到subversion存储库的子目录中

将git存储库克隆到subversion存储库的子目录中,git,git-svn,Git,Git Svn,我有一个现有的SVN存储库,它有一个“公共”目录,其中包含由不同项目共享的模块。 布局如下: http://example.com/svn/trunk/common/module_1 http://example.com/svn/trunk/common/module_2 ... http://example.com/svn/trunk/common/module_X 出于各种原因,我正在使用git管理其他一些项目。 我需要在SVN和git项目中使用模块X,所以我计划使用git SVN。 但是

我有一个现有的SVN存储库,它有一个“公共”目录,其中包含由不同项目共享的模块。 布局如下:

http://example.com/svn/trunk/common/module_1
http://example.com/svn/trunk/common/module_2
...
http://example.com/svn/trunk/common/module_X
出于各种原因,我正在使用git管理其他一些项目。 我需要在SVN和git项目中使用模块X,所以我计划使用git SVN。 但是,出现以下问题:

user@host:/repos$ git svn clone http://example.com/svn/trunk/common/module_X destination
此命令将在/repos/destination中创建一个新的git存储库,并将模块X内容提取到其中。 我需要完成的是将模块放入/repos/destination/module\u X,而不是将其内容直接放入/repos/destination/

一开始似乎是一种选择,那就是使用

user@host:/repos$ git svn clone =--ignore-paths='^((?!module_X).*)$' http://example.com/svn/trunk/common/ destination
它将在/repos/destination中创建一个存储库和一个子目录/repos/destination/module_X。 但问题是,我的SVN存储库有一个相当大的修订历史记录,总体上,common/路径的操作相当缓慢


有人知道如何做到这一点吗?

简短的回答:你不能,或者你不想要。Git还没有被设计为承载多个项目,因此克隆独立的子目录,一个Git==一个项目。即使你能够做到这一点(请看以下非常有见地的答案:),你也会失去与更新保持同步的所有能力

尽管您可以尝试,但可能有一种黑客行为,那就是告诉git svn为您拥有的每个模块创建一个分支,这里有一个很好的示例:,应该是这样的:

% git svn clone https://svn.myrepos.com/myproject myproject --ignore-paths='^((?!common).*)$' --trunk=trunk/ --branches=trunk/common/* --prefix=svn/
(未经测试)