davitenio davitenio - 1 month ago 11x
Git Question

Is it possible to have a Subversion repository as a Git submodule?

Is there a way to add a Subversion repository as a Git submodule in my Git repository?

Something like:

git-svn submodule add https://svn.foo.com/svn/proj --stdlayout svn-project

points to a Subversion repository.

I know there is
which allows one to interact with a Subversion repository. So I am thinking, maybe there is a way to checkout a Subversion repository with
and then use it as a submodule.


No. Your best bet would be to set up a mirror of the svn repository in a dedicated git repository.

git svn clone -s http://subversion.example.com/ myclone
cd myclone
git remote add origin git@example.com:project.git
git push origin master

Then you can add the git repository as a submodule to the original project

cd /path/to/gitproject
git submodule add git://example.com/project.git -- svn-project
git add svn-project
git commit -m"Add submodule"

There is one conceptual difference between svn:externals and git submodule that may trip you up if you approach this from a subversion point of view. The git submodule is pegged to the revision that you give it. If "upstream" changes, then you have to update your submodule's reference.

So when we resync with the upstream subversion:

cd /path/to/myclone
git svn rebase
git push

... the git project will still use the original revision that we committed earlier. To update to the svn HEAD, you would have to use

cd /path/to/gitproject/svn-project
git checkout master
git pull
cd ..
git add svn-project
git commit -m"Update submodule"