简体   繁体   中英

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. 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. I need to use module_X in both SVN and git projects, so I'm planning to use 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. 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/ .

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 . But the problem is that my SVN repository has a rather large revision history and opreations on the whole common/ path are rather slow.

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. 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.

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 clone https://svn.myrepos.com/myproject myproject --ignore-paths='^((?!common).*)$' --trunk=trunk/ --branches=trunk/common/* --prefix=svn/

(untested)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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