Most of the projects I work on are using git but there are still a few projects that are kept in subversion. There's nothing wrong with svn, it's perfectly fine but git does make it convenient to work on different features locally.
In the past I've moved projects from svn over to git by simply doing svn export then adding the exported code base to git. The drawback here is that you lose all the commit history and tags/branches.
Fortunately it's possible to migrate a svn repository over to git whilst keeping all of the history and some of the developers at Atlassian have made a handy tool to make it even easier.
Naturally you'll need svn and git but you will also need git-svn, Java, and 'svn-migration-scripts.jar' (available from BitBucket).
I did the process on a Fedora Linux system (you should use a caps specific system) so the commands used on this page could differ. For full details of the process you can refer to Atlassian's Migrating Overview page.
To start off make sure you have git-svn:
sudo yum install git-svnThen if you havn't already downloaded it, get the svn-migration-scripts.jar:
wget https://bitbucket.org/atlassian/svn-migration-scripts/downloads/svn-migration-scripts.jarThe first part of the migration is to map all the users that have done a commit to the svn repo, to their corresponding git user. To do this use the migration-scripts tool then manually edit the generated 'authors.txt' file:
java -jar svn-migration-scripts.jar authors https://mydomain.com/svn/repos/myproject/ > authors.txtFor every user that has done a commit to the project in the svn repo, map them to a name/email combination that is used by git. eg:
BGATES = Bill Gates email@example.comOnce that's done it time to get git-svn to get all the commits from the svn repo:
git svn clone --stdlayout --username=Change in to the newly created directory that the code has been cloned to. It's worth noting that git can be configured to a particular user both globally and for a particular repository so you may want to set your name/email for the repository before continuing:
SVN_USERNAME_HERE --authors-file=authors.txt https://mydomain.com/svn/repos/myproject/ myproject
git config user.name "name"Now to convert all the svn tags to tags in git (assuming you have the standard svn layout of tags, branches, and trunk):
git config user.email "firstname.lastname@example.org"
java -Dfile.encoding=utf-8 -jar ../svn-migration-scripts.jar clean-git --forceThat's just about it. Assuming you already have an ssh key and a remote git server to push to then you can add the remote is the usual way and push the code. Note that by default git won't push the tags up to the server so use '--tags' or '--all' (not both):
git push -u origin master --all