Migrating a SVN Repository to GIT

Yesterday I took on the task of migrating a remote SVN repository to GIT. 

I recently bought a small cloud server from Rackspace with the goal of amalgamating various services I had hosted previously at Webfaction.

The SVN –> GIT migration was simple and painless (thanks to Jon Maddox for the reference instructions).  Importantly, all the commit history from Subversion was maintained.

 

Create a new git user:

adduser git

 

As the git user

mkdir repos

cd repos

mkdir trunk_tmp

cd trunk_tmp

git-svn init http://x.y.z/svn/trunk –no-metadata

git config svn.authorsfile ~/repos/users.txt

git-svn fetch

 

The *users.txt *should contain a mapping of svn to git users in the following format:

svnusername = My Full Name

 

After the git-svn fetch operation has completed (it will download all revisions from subversion and may take a while), do the following:

git clone trunk_tmp trunk

rm –rf trunk_tmp

**

~git/repos/trunk is the new home of your GIT repository.

 

To access it remotely (over ssh):

git clone ssh://git@/~git/repos/trunk

 

Simple as that.  I’m the only one using the repository so tunnelling it over a single user account is satisfactory.  I’d recommend setting up ssh private/public keys to make authentication more seamless.

 

Resource