GitHub

written by daniel on February 9th, 2008 @ 01:00 PM

Update: Since I wrote this, I found out the git-svnimport is deprecated. The good news is that the process is now much easier!

I started importing a bunch of our Rails plugins into GitHub this morning.

I used git-svnimport because I want the entire svn history converted to git.

A couple of issues proved problematic:

  1. Our plugins were in a single svn repository and not the typical trunk and branches setup:
    rails/plugins/acts_as_audited
    rails/plugins/acts_as_geocodable
    …
    rails/plugins/with_action
    

    To get this to work, you use the root of the repository as the path and pass -T with the path you want to fetch.

    git svnimport -T plugins/acts_as_audited http://source.collectiveidea.com/public/rails
    This is totally fine with git svn. Don’t worry about it. I strongly recommend putting each plugin (or project) into its own git repository, as it will make your git life easier.
  2. Usernames in svn are stored just as our unix usernames (brandon, daniel). For git, I want to use our email addresses.

    For that, you make a file of all the authors in the format

    username = User's Full Name <email@addr.es>
    and pass -A path_to_author_file

    git svnimport -T plugins/acts_as_audited -A ./authors http://source.collectiveidea.com/public/rails
    git svn clone http://source.collectiveidea.com/public/rails/acts_as_audited -A ./authors
  3. Finally, to save trouble, I want to create a new git repository. Trust me, its just easier. Pass in the path you want. -C some_path

    git svnimport -C acts_as_audited -T plugins/acts_as_audited -A ./authors http://source.collectiveidea.com/public/rails

That’s it! After that, you have a git copy of your repository and can push it to GitHub, or do whatever you want.

Here’s the final command for reference (I added -v for verbose):

<del>git svnimport -v -C acts_as_audited -T plugins/acts_as_audited -A ./authors http://source.collectiveidea.com/public/rails</del>
<ins>git svn clone http://source.collectiveidea.com/public/rails/acts_as_audited -A ./authors </ins>
git svnimport -v -C acts_as_audited -T plugins/acts_as_audited -A ./authors http://source.collectiveidea.com/public/rails
git svn clone http://source.collectiveidea.com/public/rails/acts_as_audited -A ./authors 
You may get some errors like W: Ignoring error from SVN, path probably does not exist: and HTTP Path Not Found: REPORT request failed. These are fine. Ignore them.

Check out our projects on GitHub.

Comments

  • Kevin Ballard on 17 Feb 16:57

    You really should use git-svn, not git-svnimport. The latter has been deprecated.

  • Daniel Morrison on 18 Feb 21:43

    Kevin: Yep, I found out it was deprecated a couple days after posting this.

    I hadn’t updated to git 1.5.4 yet, so I guess I should rework these instructions.

Post a comment

Options:

Size

Colors