How to migrate from SVN to Git on Windows using TortoiseGit/SVN clients

Problem

My setup is simple. I have external HDD hooked, where I got my local repositories (for both Git and SVN). Being local file storage, all the navigation/URLs is done with file:/// prefixing. For version control, I usually use both TortoiseGit and TortoiseSVN clients, but now, I wanted to move one of my project from SVN repository to Git repository. It all seemed simple:

  • have the original svn repository for Project located at F:\SVN_Repository\Project
  • targeted git repository for Project should be at F:\GIT_Repository\Project
  • use git clone from SVN repo command to preserve commits history

Unfortunatelly, TortoiseGit had other plans and displayed such error message:

Couldn't open a repository: Unable to open an ra_local session to URL: Unable to open repository 'file:///F:/SVN_Repository/Project/trunk': Expected FS format '2'; found format '4' at ...

Solution

After some quick googling, it turned out to be well-known issue with TortoiseGit, and solution was apparently simple - all you have to do is serve SVN repository to Git via svnserve service:

  1. First, you need to get and install svnserve.exe. I wasn't able to find it anywhere on my box, so I figured it doesn't come with typical TortoiseSVN installation.
  2. Following guide from the link above, I've grabbed Subversion installer from SlikSVN. You can get whichever you like, just make sure it comes with svnserve.exe (as this is our main star in this show).
  3. When installing, double check that SVNServe is actually going to be installed (for example, typical install of SlikSVN I used didn't have it, so I had to manually select it in custom install).
  4. Once installation completes, navigate to installation directory and start svnserve.exe process, pointing it to your local SVN repository:

    cd "C:\Program Files\SlikSvn\bin"
    svnserve.exe --daemon --root F:\SVN_Repository

  5. To verify whether svnserve hooked up to your repository correctly, open Repo-browser for project you are migrating. The URL should use old format, with file:///SVN_Repository prefix - you need to replace it with svn://localhost/:

    old:
    file:///SVN_Repository/Project
    new:
    svn://localhost/Project

  6. If repo browser window correctly displays your project structure, it's all good.

  7. Now, all you need to do is use git clone which failed at the very beginning (this will take a while as Git is going to rewrite entire commits history into its own format):

git clone

At this point it is job done. However, I didn't really like that Git was hooked to SVN (context menu has extra svn-related commands, which I didn't plan to use) and all that weirdness, so I decided to push entire project into brand new Git repository and clone that to my working directory:

  1. Create bare repo for your project in external storage directory (F:\GIT_Repository\Project).
  2. Point your SVN-migrated, now Git project's origin to that repository (put bare repo path into URL box of TortoiseGit -> Push -> (Destination) Manage window).
  3. Push master to your new repository (this will naturally push entire commits history).
  4. git clone project from Git repository to your local workspace.

SVN has left the building, and the only reminiscence of it is git-svn-id tag in your commits history. For the sake of completeness, rebuild your project and run unit tests :-)


Comments

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
Solve the challenge for fame and fortune!