Migrating from SVN to GIT

One of the big benefits of using source code versioning (or source code management systems) is that it allows you to maintain a history of all the changes in code and allows for easy collaboration amongst several developers on the same code base. SCMs will allow you answer the following questions:

  1. Who made what change
  2. What change was made
  3. When was the change made

If you happen to have a number of developers and you’re working on the same project (even if you’re the only developer, this helps) you like to know when a change to the source code breaks the application (this happens alot). Not only that, having an SCM allows you to easily revert that change. This post is not about SCMs but I thought it necessary to provide a little background information.

I recently started using git and have really loved it (although it’s not perfect, it does the job well). I prefer git over subversion (svn) for a major reason that it is distributed: does not require a connection to a server in order to commit to the repository.

Recently, I thought about migrating my svn repositories to git and I found a wonderful resource for that here. I’m not going to attempt to republish what has been said there here. Instead just point out a couple of things I had to do differently.

First of all, depending on the way your git is installed, these are basically the commands to run:

git svn init svn://server/repo/trunk/ --no-metadata
git config svn.authorsfile /path/to/svn-authors
git svn fetch

The difference here is to use git svn instead of git-svn. Also, if you happen to have blank authors (as I had in mine), then your svn-authors file should contain an entry similar to this:

(no author) = Firstname Lastname <emailaddress>

September 3, 2009

5 responses to Migrating from SVN to GIT

  1. What is even more wonderful about git is the power of its branching.

    The ability to quickly switch between various versions of the app you’re working on, so that you can … for example … go from working on a feature, to making a bug fix, pushing it live then go back to working on your feature … is very compelling.

    enjoy.

  2. Tim said:

    You’re right Austin. Welcome to my blog and I do hope to see more of your comments. Have you heard about stashing in Git? It’s good for those quick bug fixes that you need to make without having to first create a branch.

  3. Yes I’ve heard of stashing ;)
    And yes … it is pretty rad.

  4. Faiz said:

    Have u taught of Mercurial. I think it is the next big thing and large sites that host open source codes like Google code are moving from Subversion to it.
    Netbeans is fully using it now.

  5. Tim said:

    Hey Faiz, your first comment here? Welcome :) I have heard about Mercurial and yes I do agree with you that it’s really gaining some attention these days. It appears to be more robust than Git. I’ve found git to be slow when you’re dealing with really large codebases. I haven’t considered a switch to it majorly because of the teams I’m working with.

    With the kind of projects being migrated to Mercurial, I’m sure it wouldn’t be long before I make the switch.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>