Migrating from SVN to Git

I’m in the process of cleaning out my old PC and moving the content over to my iMac.  As part of the process, I’m converting an old Subversion repository that held a bunch of my side projects into several smaller Git repos.  Here’s the general flow for each of my projects (Warning: these notes are really just for me.  I’m still learning git and am probably doing this wrong.):

git svn clone svn://localhost/ –username=aaron –preserve-empty-dirs –authors-file=authors –no-metadata –include-paths=”^path/to/project1″ project1

cd project1
git filter-branch --prune-empty --subdirectory-filter "path/to/project1" HEAD

I repeated that  a few times, then to get the miscellaneous scraps, I did:

git svn clone svn://localhost/ --username=aaron --preserve-empty-dirs --authors-file=authors --no-metadata --ignore-paths="^path/to/(project1|project2|project3)" misc_svn

cd misc_svn

git filter-branch --prune-empty

I don’t know if that last step was required.

Once I had working git repos on the PC, I shared the directory that contained them all, and connected to that folder from my Mac.  Once connected, I could easily clone them with:

git clone file:////Volumes/git/project1/

So far, it looks like it worked well.  Each project has just the parts of the log that it needs, but it still retains the history.

2 Responses to “Migrating from SVN to Git”

  1. Chris Kenst Says:

    How do you like using Git now? Have you considered putting stuff in your GitHub account? By the way your git commands go off the screen in this blog post – you might want to re-arrange.

  2. Aaron Says:

    I like Git, but I haven’t been using it much lately. I have some stuff on my GitHub account, but nothing big. Not much time for coding at home these days and my group at work doesn’t use it. 🙁

    Good point on the text going off the screen. If I get some time, maybe I’ll figure out how to restyle it. For now, people who want to use my commands (and I don’t really recommend that they do) can copy/paste them into a text editor or something.

Leave a Reply