Migrating a Legacy Repository from SVN to Git on Windows

There may come a time when you stumble upon an ancient SVN repository nested with multiple projects and need to efficiently collaborate with others on a single project in that repository. Well, we all know Git is better than SVN in many ways. It’s faster and the decentralized, distributed nature of Git provides better security and redundancy. We all remember the story of codespaces.com, where a single hacker hacked into their Amazon servers in the cloud and they were forced to shut down. All users who had their single SVN repository on codespaces.com lost it all.

There is a simple tool that migrates SVN to Git quite well. Atlassian has provided documentation on how to do this with their custom tool, however it’s slow and does not work well on Windows. Using the svn2git gem, migrating a 400MB SVN repository is a breeze and only takes a few minutes.

  • Download the Ruby for Windows installer.
  • Download the svn2git gem: gem install svn2git.
  • Create a new empty folder for the git repository
  • Run svn2git.bat <svn-project-sub-path> –no-minimize-url
  • Be sure to add a .gitignore file then, commit and push to the remote origin.

That’s it! Still need to keep your SVN repository in sync for some strange reason? Check out the SmartGit Client.


How to Get the Latest from Subversion

Let’s say you are using Subversion as your source code control system and you want to have a batch file retrieve the latest source code from trunk. You may execute the following statements on a directory that already has been checked out.

The common practice is to always update the repository for checking in new code in order to resolve local conflicts and ensure the build compiles locally.

@echo off echo Getting the latest version of the MyRepo files… svn cleanup C:\Repositories\MyRepo svn update C:\Repositories\MyRepo

Here is another tip when using source code control: Never group several projects into one repository. Always create separate repo for each projects. This makes it easier to branch off and collaborate with others.