HowTo: Convert Subversion to Git

To make a start I can say that I personally prefer using Git as Version Control System. I use Subversion and Mercurial for some reasons too, but I do not really like to work with them.

Because of this I wanted to convert some Subversion repositories to Git. If you also have planned to do this, the following may help you.

Three different ways for the conversion:

  1. Copying the source code:
  2. The easiest and fastest way is simply copying the source code into an empty Git repository. For me this solution was impracticable, because you will loose the history.

    # Create and switch to new folder
    mkdir $GIT_REPO
    cd $GIT_REPO

    # Copy all files from the Subversion directory
    # Use -C option to ignore .svn directories

    # Do the Git steps
    git init
    git add *
    git commit -asm "Initial commit"

  3. Using git-svn:
  4. The next way to convert the repository is using git-svn. With git-svn you are able to adopt all branches and the whole history. The only unsuitable thing is converting tags, because they are created as branches by default and you need to switch them manually afterwards.

    # Install the software
    (sudo) apt-get install git-svn

    # Make and switch to new folder
    mkdir $GIT_FOLDER
    cd $GIT_FOLDER

    # Convert the repository
    git svn clone $SVN_URL --no-metadata --stdlayout .

    # Update the repository
    git svn fetch

  5. Using svn2git:
  6. Svn2git is a utility which uses git-svn internally to do the real conversion, but in addition it does some more jobs around this to perfect the system. With this you will have a accurate converted repository. It uses Ruby, so you need to install some additional packages.
    You can use svn2git for some special actions and custom purposes. If you need some more information you can take a look at the README.

    # Install the software
    (sudo) apt-get install git-svn ruby rubygems
    (sudo) gem install svn2git

    # Make and switch to new folder
    mkdir $GIT_FOLDER
    cd $GIT_FOLDER

    # Convert the repository
    svn2git $SVN_URL

    # Update the repository
    svn2git --rebase

I hope this tutorial helps you to save some time and troubles. If you have feedback, regards, corrections or questions please let me know and do not hesitate to comment!

I will probably write something about Version Control Systems, like a comparison or Cheat-Sheets, in other blog posts.

Gitlog Parser

Sometimes I needed a possibility to convert the output of the `git log` command in a useful format. Because of that I have written a tool in Perl, which is currently able to convert this output to different file formats.

Here is a short overview of this tool:

  1. Link:

  3. Get it:
  4. # Clone from github
    $ git clone git://

  5. Current supported formats:
    • SQL-Dump
    • RSS-Feed
    • HTML-Page

  6. Documentation:
  7. You can find the documentation in the README file of my github repository.

  8. Sample usage:
  9. # Change to GitParser directory
    $ cd YOURPATH/GitlogParser
    # Show help
    $ ./scripts/ --help
    # Execute script for RSS output
    $ ./scripts/ --repo PATH-TO-GIT-REPO

    The –repo option is the mandatory option to state the git repository. Of course there are other options to customize the output for your purposes. For example you can specify the title of your RSS-Feed with the –title option. If you want to know more about the other options please take a look at the documentation or use the output of the –help option.

  10. Sample output:
  11. RSS

This tool is not finished completely and I will probably implement support for more file formats. If you have suggestions or any feature request please do not hesitate to contact me via github!