Migrating a SVN Repository to GIT
20 Jun 2010Yesterday 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
- http://git.or.cz/course/svn.html – Provides a reasonable mapping of SVN –> GIT commands.
- http://www.jonmaddox.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/ – More detailed instructions on the repository migration.