Interacting a local git repository with a subversion one has been very useful and is very common on old projects. The way to do that is by using the git svn commands. But sometimes there are situations where there is one large repository with several projects as subfolders in that repo.
Using the standard svn cloning command:
git clone my_svn_repo_server.com/repository
Code language: Shell Session (shell)
Will checkout the whole SVN repository (all subfolders, hence, all projects) into your local machine. This can be very large if the codebase and history is big, and very slow to interact with, since getting your local repository updated will involve getting changes from all other projects.
To make git clone a subdirectory from an SVN repository, use the following:
git svn init http://my_svn_server.com/repository/path/to/directory/of/project
git svn fetch
Code language: Shell Session (shell)
This way you not only clone that subdirectory, but also you will get updates from only that folder, making faster code pulls and pushes to the central SVN repository.
While I consider a very bad practice to have one large Subversion repository with several projects inside it as subfolders, I’ve come across such setups several times and it drove me crazy to have to checkout the whole thing. Hope this helps out.
6 replies on “Using Git with Subversion repository subdirectory”
Thank you so much! I was looking for that for week.
Thank you so much.
Finally something which I was looking for since last week. I hope once the fetch completes I will get what I was looking for.
I just have one doubt, what after fetch is done. How do we keep synch between SVN repo and Git?
How to migrate for example two subdirectory from svn to one git repo ?
Gracias!! casi toda la documentación que encontré hace `git svn clone`, que es imposible hacer en el repositorio gigante de mi trabajo. Esto es justo lo que buscaba.
Un gusto poder ayudar 🙂