You are such a Git

I've been trying to migrate from using Subversion to Git for my version control. If you need to keep track of the different stages in the development of some work (this usually refers to code but could easily be a paper), you should be using version control.

I've been using SVN (often called Subversion) for nearly 10 years and I'm sick of it, so I thought I'd give Git a try. The organization I work for (Las Cumbres Observatory) is a non-profit so we applied for a free organization membership of GitHub (an online repository which will keep all your revision history and has a snazzy web interface). The problem was we have lots of software projects and lots of revision history we didn't want to lose by giving up on SVN.

Fortunately, lots of people are in this position so there is a project called SVN2Git which will do the hard work of porting all your SVN history over to Git formatted history. It will even change your SVN users to GitHub users for a little more interactivity.

Step 1.

Install svn2git - You'll need to have "git svn" installed. I'm on a Mac so I had to install Git from Homebrew, not from the .pkg distribution to get svn git.

Step 2.

Create a new directory/folder for the files you will convert from SVN to Git.

Step 3.

Set up an authors file in the correct GitHub format. This will translate your SVN users to GitHub users. You need to have every user who made commits on the SVN project using GitHub. I saved it as authors.txt in the current directory. The format is as follows
svn_username = Real Name  

jdowland = John Dowland 
wbyrd = William Byrd

Step 4.

You will then run svn2git on your repository (not your local working copy) which will checkout a copy of the whole repository (trunk, branches and tags) and all the revision history. It will then convert all of that into Git format.
svn2git http://path/to/remote/repository --authors authors.txt

Step 5.

Create a repository on GitHub, and tell your newly Git converted project to point at your GitHub repository:
git remote add origin [email protected]:USERNAME/REPOSITORY_NAME.git

Step 6.

Merge your  newly converted project with the blank repository you created in step 5.

I had to "pull" down a copy of the files from GitHub (which were just the .gitignore and files). Without doing this step I had lots of errors including SSH port 22 fatal error - sounds more alarming that it really was (Git is a bit of drama queen).

git pull [email protected]:USERNAME/REPOSITORY_NAME.git master

Next you will merge the files that svn2git converted for you,
git push [email protected]:USERNAME/REPOSITORY_NAME.git master

All of your files should have made it into GitHub, complete with committers linked to GitHub users and a full verion history.