SVN2Git and "fatal: bad default revision 'HEAD'"

I was recently converting a repository from SVN to Git using KDE's SVN2Git, and after the conversion was done, the repository didn't seem to work that well. Inside the bare repo, if I tried git log, I received:

<br />
fatal: bad default revision 'HEAD'<br />

I also tried git fsck, which resulted in:

<br />
notice: HEAD points to an unborn branch (master)<br />

After trying a few different methods to resurrect the git repository, I noticed that my SVN2Git rules file defined the name of the resulting git repository as example-example (note the dash). Removing the dash fixed the issue, and now I have a happy git repository!

tl;dr: Don't use special characters in the name of the resulting git repository in SVN2Git's rules file.

Switching an SVN repository to Git using git svn

Converting from an SVN repository to a Git repository is fairly simple—you just want to move all the commits across, preserve your tags and branches, and make sure all the commit authorship translates properly. The simplest method (though not always fastest) is to use the git svn command to do the full conversion. (Note also that you could interact with an SVN repository with Git as the middle man using git svn... but this blog post is just about doing a full conversion).

Converting the authors

Before you convert the SVN repository to Git, you need to get a list of all the SVN commit authors, and then set up the list for git svn to be able to translate SVN commit authors to Git commit authors (the Git format is slightly different, using a name + email combination). First, in a terminal window, run the following command within a local checkout of the SVN repository:

Switching an SVN repository to Git with KDE's Svn2Git

Some places where I've worked have used SVN for version control, and while the supposed simplicity and centralization of SVN can be nice in certain situations, SVN can't hold a torch to Git's speed, flexibility, and ubiquity (nowadays) for source control. Not to mention SVN doesn't have real tags or branches, just quasi-directories that can easily be mangled into a horrific mess (I see this quite often).

I've had to use some incredibly large (10,000+ revisions, 2GB+ total size) SVN repositories, and while I've managed them using git svn sometimes (see Switching an SVN repository to Git using git svn), it's much nicer to be able to migrate the entire team from SVN to Git so everyone can work on the repository much more efficiently.