How to use SVN and Git together to get the best of both worlds in Windows

I have been using SVN to manage my source code for last three years, I can say I am quite happy with it, except for one problem, it was not possible to commit the code unless I was directly connected to my office network.

Then I heard about DVCS and Git. I found solution to one of my big problem, ability to commit code while I am not connected to office network, and share code with my teammates.

Their was only one small problem we didn’t wanted to loose the benefits of centralized repository, and we use Windows  OS( let’s not get into windows vs linux, i will win). So last 3-4 months I was looking for different DVCS systems with better windows support and i experimented with Mercurial (TrototoiseHg is good), but i think Git wins the race of DVCS hands down, and with popularity of GitHub I don’t see much choice here.

And finally I found about git-svn, and I was on my way.

Here are the commands and steps that you can use to manage Git and SVN together.

  1. Create a working copy(or actually a git repository ) using
    git svn clone –s <path to ur svn rep, eg https://akjoomgallery.googlecode.com/svn/trunk/>
  2. Get the source from svn repository to your git repository using
    git svn fetch

    (only needs to be done first time, it is slow and time consuming process)

  3. When you need to update your working copy  you use
    git svn rebase
  4. When you need to commit back to svn repository just use
    git svn dcommit

I used above commands in Git bash shell that comes with Git.

Also note their would be time when we have some changes in the Git repository that is not yet ready for commit, but we need to update our repository and Git won’t let you do that, without committing them (rebase will always give error) in such situation you use following set of commands

git stash

git svn rebase

git stash apply

git stash clear

Update:

And if you don’t want to these things manually here is my favourite tool that does that using nice GUI and perfect windows integration TortoiseGit

I have written this a month back before I found TortoiseGit, so this is now just for reference, and to get me back to my blogging.

Have fun.

One thought on “How to use SVN and Git together to get the best of both worlds in Windows

  1. Hi
    Thanks for your tutorial , it’s opened a few doors for me
    but I still a question maybe you would have an idea about :
    I have a large SVN repo
    I’ll be outsourcing one folder ‘themes’ to an external team who can’t have access to the complete svn repo.
    I( seems ‘git svn’ would be a way to go ,
    but I’m still quite new to git and don’t have a clue on how to proceed.
    any help would de great
    Thanks
    Tibor

Comments are closed.