Moving your SVN repositories to Git on BitBucket
Now that Atlassian comes with free hosting for private Git repositories there's really too great of a tentation to go and try how that would work.
If you're rather small group of developers (five or under), Atlassian's alternative sound tempting when considering one of the big three: Google Code (no private repos), GitHub (all private repos cost something), BitBucket (free private repos for five developers).
We chose BitBucket!
Now the process of migrating SVN to BitBucket Git is actually pretty simple:
Install git and git-svn
So we're assuming you're using Ubuntu or other distribution using apt. If not, just search how to install these packages into your system.
sudo apt-get install git-core git-svn
Convert the usernames
Subversion users are normally listed in
These are simple usernames with now email addresses. In BitBucket all users must have an email address as well. Thus, let's make a authors.txt file listing all your SVN users like this:
username1 = Firstname Lastname <email@example.com>
username2 = Firstname Lastname <firstname.lastname@example.org>
Convert a SVN repo to a Git repo
Change the references to the svn repositories (we have it hosted locally) and hit the following command:
git svn clone svn://localhost/svn/myrepo/ -A authors.txt -b branches -T Trunk -t tags my_repo
If you don't have branches or trunk in your repository, use the following:
git svn clone svn://localhost/svn/myrepo/ -A authors.txt my_repo
If you're getting the following error:
Author: (no author) not defined in authors.txt file
Just add this line to your authors.txt
(no author) = none <email@example.com>
By the way in case you have (as many of us do) svn ignores, you can translate these to Git language as well. Go to the newly created folder and type:
git svn show-ignore -i trunk > .gitignore git add .gitignore git commit -m 'Converting svn ignore properties to Git equivalents'
Make a bare Git repository
Go back to the parent folder of my_repo and do the following:
git init --bare my_bare_repo cd my_bare_repo git symbolic-ref HEAD refs/heads/trunk cd ../my_repo git remote add bare ../my_bare_repo git config remote.bare.push 'refs/remotes/*:refs/heads/*' git push bare cd ../my_bare_repo git branch -m trunk master
Again, if you didn't have the trunk folder in your repository, the last command will fail. You can instead do the following:
git branch -m git-svn master
Importing your new Git Bare repository to BitBucket
Log into your BitBucket account and create a new repository (my_repo here). Find the route to your repository (where it says git clone http://..., copy the http part).
Now go back to the folder where you have your Git Bare repository, and type the following:
git remote add origin https://firstname.lastname@example.org/myname/foobar.git git push origin master
This will push your repository to BitBucket. Check back to BitBucket and you'll see your SVN history nicely under the BitBucket users you indicated in the authors.txt.