How to import a svn repository underneath a git repository?

I have a svn repository that I migrated to git using the tool svn2git. Now I would like to push this git layout to a remote repository underneath an existing directory. But, I would like to keep the svn history (tags and branches). For instance:

Git remote repository layout:

git-repository/dirA
git-repository/dirB
git-repository/dirC/svn-repository-migrated-to-git

Makes sense? Is it possible??

Thanks

Upvotes: 1

Views: 299

Answers (2)

Tobu
Tobu

Reputation: 25446

Check out your outer git repository, add the imported git repository as a remote, and use git-subtree to make the imported repository a subtree of the other.

git clone git://path/to/remote/repo
cd repo
git remote add -f ../path/to/imported
git subtree add --prefix=subdir/ imported/master
git push

You should think the tag and branches requirement over, though. You are combining an outer repo having n branches with an inner repo having m branches. What are you going to do, create n×m branches?

If you want to preserve the branches of the imported repo, give it its own repository and not a subdirectory.

Upvotes: 2

Peter Tillemans
Peter Tillemans

Reputation: 35341

I do not think this is directly possible.

You can though use git submodules to "link" dirC to the repository just created.

Would that do?

Upvotes: 1

Related Questions