14 December 2011

Migrate from SVN to Git

There is lots of article about migration from SVN to Git (a powerful distributed version control system), but I didn't find all needed information in only one.
This is the aim of this article.

Instead of blabla, I take the concrete example of the migration of my open-source project Hemera :

 - create an author file linking information between commiter name, user name, and user e-mail:
/tmp/authors
projettwk = Bertrand Benoit

 - create a Git repository from SVN repository
git svn clone --no-metadata -s -A /tmp/authors https://hemerais.svn.sourceforge.net/svnroot/hemerais hemera

 - update Git repository metadata, removing SVN information (more information)
git fetch . refs/remotes/*:refs/heads/*
git branch -rd 0.1 trunk
git branch -d trunk
git config --remove-section svn-remote.svn
rm .git/svn/ -Rf

 - create a bare Git repository metadata (more information: here, and here)
git clone --bare /tmp/hemera/.git /tmp/hemera-bare.git
cd /tmp/hemera-bare.git
git config --unset remote.origin.url

 - publish the fresh bare Git repository (more information)
git remote add origin ssh://XXX@hemerais.git.sourceforge.net/gitroot/hemerais/hemerais
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git push --all

 - finally, get a local Git repository (with write access)
git clone ssh://XXX@hemerais.git.sourceforge.net/gitroot/hemerais/hemerais

No comments:

Post a Comment

Thank you for your visit, let's share your point of view: