Converting From Subversion To Git

16
Nov

Now that I have basically fallen for Git, I decided to finally move my Subversion repository over to Git (this way I can finally have a remote backup of it that I am comfortable with on Codaset).

The method for this was a lot more straightforward than I expected it to be. For the conversion tool, I used Nirvdrums fork of svn2git. It a feature complete version of the svn2git portion though the rest of it is still is development. Since it is a Ruby gem, getting it installed was a breeze. Just make sure that you have Ruby and rubygems installed.

1
2
3
4
5
beacon:svnwork elubow$ sudo gem install svn2git --source http://gemcutter.org
Successfully installed svn2git-1.3.1
1 gem installed
Installing ri documentation for svn2git-1.3.1...
Installing RDoc documentation for svn2git-1.3.1...

Then I created a authors.txt file to make sure the subversion committers got transferred over to Git cleanly. The file looked like this:

1
2
beacon:svnwork elubow$ cat ../authors.txt
elubow = Eric Lubow <myemail@here.com>

Then I went to my Remote Code Storage Location of choice (Codaset) and created an empty repository for my personal files. I then cloned the repository to my local machine:

1
beacon:svnwork elubow$ git clone git@codaset.com:elubow/personal-files.git

Then I changed into the directory of the personal-files git repository and ran the following command:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
beacon:personal-files elubow$ svn2git file://localhost/Users/elubow/Library/Subversion/work --rootistrunk --authors ../authors.txt
Checked out HEAD:
  file://localhost/Users/elubow/Library/Subversion r234
Note: moving to "trunk" which isnt a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
  git checkout -b <new_branch_name>
HEAD is now at e4708ee... Updated mail tools to latest versions
Switched to a new branch "master"
Counting objects: 668, done.
Delta compression using 2 threads.
Compressing objects: 100% (595/595), done.
Writing objects: 100% (668/668), done.
Total 668 (delta 280), reused 0 (delta 0)
Removing duplicate objects: 100% (256/256), done.

beacon:personal-files elubow$ ls -l
total 0
...
Actual stuff here but removed for brevity
...

The entire process took me about 15 minutes. Then I did a simple git push back to Codaset to save all my changes.

1
2
3
4
5
6
7
8
9
10
beacon:personal-files elubow$ git push origin master
Counting objects: 668, done.
Delta compression using 2 threads.
Compressing objects: 100% (315/315), done.
Writing objects: 100% (668/668), 240.37 KiB, done.
Total 668 (delta 280), reused 668 (delta 280)
=> Welcome to Codaset
=> Syncing Codaset... To git@codaset.com:elubow/personal-files.git
 * [new branch]      master -> master
[OK]

2 Responses to “Converting From Subversion To Git”

  1. […] This post was mentioned on Twitter by mikehenke, Eric Lubow. Eric Lubow said: Finally caught up on some #blog posts this weekend. Latest is up on converting from #svn to #git: http://bit.ly/1hpySB more to come. […]

  2. Social comments and analytics for this post…

    This post was mentioned on Twitter by mikehenke: Converting From Subversion To Git – http://bit.ly/oric4

Leave a Reply