Using Git and SVN at the same time

I am a big fan of Git, the distributed source control system created by Linus Torvalds and using on the Linux kernel. The system is really fast, and it is so configurable that it makes life really easy (at least after you learned enough about how it works).

But the reality of the of industry is still very different from what we can do on open source. Companies don’t want a distributed system, because they like to have control of code in a central location. That is why not even Google is using Git these days (they use Perforce, a closed source control system).

The big advantage of Git, however, it that is doesn’t need permission from management to be used in your local machine. And since Git works on a local machine is well as in a server, this is all you need to have a lot of fun.

Playing with Git and Svn

My first try at Git was as a local client for Svn. The general idea is that you can get Git to checkout your project and translate all Svn information into its internal format. That way, you can work with Git locally, and after doing your local development, push the commits to the Svn server.

That worked for me for some time, as I was learned as all pieces worked together. The problem that I had, however, was due to the fact that the Svn importer for Git is not as stable as Svn itself. That is, from time to time there would be some problem in the import/fetch phases, and since you depend on the importer to get anything from Svn, you are in pretty bad shape if that happens.

It also contributed to my problem the fact that my project uses non-standard names for branches, and that they are moved from time to time (don’t ask me why).

I learned the hard way that it maybe easy to use any one of two version control systems, but it is not so easy to mix them…

Trying Git a Second Time

My next try was to use something a little easier. Instead of using Git full time as an svn client, what I do now is to use svn as always (through Tortoise-svn). Then, on top of Svn, I use git to handle changes between Svn commits.

The setup is really easy. The first step is to have a normal Svn tree. Then, use the command

git init

to create a .git directory. Since Git uses only a single directory to hold all its internal information, it will not interfere with the information kept by svn itself in its .svn directories.

Now, I can just hack and commit code on git as I go. Then, when a feature is complete after several small iterations, I can do a Svn commit. I can even decide to spend a long time working on Git, and then go back and make incremental Svn changes. I can also decide to keep hidden branches on Git alone, and merge then only when needed to check in to Svn.

All this can be done without much trouble. The only added work is that I need to do some extra commits to Svn, to make sure that my work is integrated with the other developers, but the fact that everything was ready on Git makes things much easier — I can even use the same summaries.


As any interesting idea, this is one is not new. I just did a quick search on “using git with svn” and found at least another person that uses this idea (see references). Which also means that I am not the craziest developer either.

I am still tweaking my setup with Git and Svn. For example, it is useful to add the .svn directories to .gitignore, as well as other binary files. However, everything has worked Ok, and I feel that this is a good solution for some problems we have when using Svn alone.


Related Articles

Similar Posts:

About the Author

Carlos Oliveira holds a PhD in Systems Engineering and Optimization from University of Florida. He works as a software engineer, with more than 10 years of experience in developing high performance, commercial and scientific applications in C++, Java, and Objective-C. His most Recent Book is Practical C++ Financial Programming.

6 Responses to “Using Git and SVN at the same time”

  1. Carlos,

    Even I started using git on svn the same way. Assuming you have been using this method since long time, let me know if there are any hick-ups you faced.

    I am guessing your answer s gonna be NONE! :)


    By Ninad on Apr 25, 2011

  2. Hi Ninad, the only issue is keeping git synchronized. Every time I commit on svn I do the same on git, and use the revision number in the comments to help identify the changes.

    By coliveira on Apr 28, 2011

  3. Hi Carlos,
    Maybe you can help me in my problem. I wish to use in my projects git and svn together. The reason is complicated. We are making webpages and we have our own cms. Well, each webpage project is different, so I want to store them in SVN version control, in different projects. But each has the cms, with is common, that I want to store in other version control as a self standing project. The cms I would store in GIT.
    My target is, that from any project I have to be able to commit in the repo of the website project and in the repo if the common cms as well.
    Can I do this?

    Thank you very much for your help!

    By Levi on Jan 12, 2012

  4. You can always have git along with svn in the same directory, but they won’t be synchronized. Git uses its .git directory, while svn uses the .svn dir. I have done this before, but it would be better to use git as an interface to svn, so that they are synchronized. Try to learn about git-svn and you’ll see how it works.

    By coliveira on Jan 14, 2012

  5. Levi, have a look at SubGit ( project. It creates a Git interface for SVN repository (so both become fully usable).

    By Dmitry on Jun 24, 2012

1 Trackback(s)

  1. Apr 17, 2016: Git + Svn | Git FAQ

Post a Comment