简体   繁体   English

将git仓库克隆到Subversion仓库的子目录中

[英]Clone a git repository into subdirectory of a subversion repository

I have an existing SVN repository, which has a "common" directory containing modules shared by different projects. 我有一个现有的SVN存储库,该存储库具有一个“公共”目录,其中包含不同项目共享的模块。 The layout is like this: 布局是这样的:

http://example.com/svn/trunk/common/module_1
http://example.com/svn/trunk/common/module_2
...
http://example.com/svn/trunk/common/module_X

For various reasons, I'm managing some other projects with git. 由于各种原因,我正在使用git管理其他项目。 I need to use module_X in both SVN and git projects, so I'm planning to use git-svn. 我需要在SVN和git项目中都使用module_X ,因此我打算使用git-svn。 However, the following problem occurs: 但是,出现以下问题:

user@host:/repos$ git svn clone http://example.com/svn/trunk/common/module_X destination

This command will create a new git repository in /repos/destination and fetches module_X content into it. 此命令将在/ repos / destination中创建一个新的git存储库,并将module_X内容提取到其中。 What I need to accomplish is to put module_X in in /repos/destination/module_X , not to fetch it's content directly into /repos/destination/ . 我需要完成的是将module_X放在/ repos / destination / module_X中 ,而不是直接将其内容提取到/ repos / destination /中

What seemed an option in the beginning was to use 一开始似乎是一种选择

user@host:/repos$ git svn clone =--ignore-paths='^((?!module_X).*)$' http://example.com/svn/trunk/common/ destination

which will make a repository in /repos/destination , and a subdirectory /repos/destination/module_X . 它将在/ repos / destination和一个子目录/ repos / destination / module_X中建立一个存储库。 But the problem is that my SVN repository has a rather large revision history and opreations on the whole common/ path are rather slow. 但是问题是我的SVN信息库具有相当大的修订历史,并且在整个common /路径上的运算速度很慢。

Does anyone have idea how to accomplish this? 有谁知道如何做到这一点?

short answer : you can't, or you don't want. 简短答案:您不能,也可以。 Git has not been designed to host multiple projects, and thus clone independant subdirectories, one git == one project. Git尚未设计为承载多个项目,因此无法克隆独立的子目录,一个git ==一个项目。 Even though you can do it (look at the very insightful answer of : How do I clone a subdirectory only of a Git repository? ), you will loose all ability to keep uptodate with the updates. 即使可以做到这一点(请看以下非常有见地的答案: 如何仅克隆Git存储库的子目录? ),您将失去所有使更新保持最新的能力。

There may be one hack though you could try, is to tell git-svn to create a branch for each module you have, here you have a good example : Cloning a Non-Standard Svn Repository with Git-Svn , something that should look like: 尽管您可以尝试使用一种方法,但还是要告诉git-svn为您拥有的每个模块创建一个分支,这里有一个很好的例子: 使用Git-Svn克隆非标准Svn存储库 ,应该看起来像:

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

(untested) (未试)

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

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