Monday, April 21, 2008

Converting Subversion Rails Project to Github

I signed up for a Github account. Github is a hosted git repository. Git is a distributed version control system focused on speed, effectivity and real-world usability on large projects. There are a couple of things I want to do with this. I want to use it as a repository for my rails apps. I also want to use it to host Rails plugins that I plan to release. Ruby on Rails has moved their repo to Github.

Before using Github, I installed Git on my PowerBook. I used the installer from Git for OS X.

I signed up for the Micro plan at $7 per month since I needed private repos. When signing up you need to provide an SSH public key. I use Linux and OS X. My public key is located in ~/.ssh/id_rsa.pub. If you don't have a public key use the following command to create one:

ssh-keygen -trsa

Enter the contents of the key file in the "SSH Public Key" box. Since I use more than one computer, I added my other SSH keys. I did this from the account page in GitHub. I also went to the profile page and added information about myself.

I created a new repository by clicking on Create a Repository.

I then imported my subversion repo using the instructions from Jon Maddox.

Set up my user translations file:

echo 'sveit = Stephen Veit ' > ~/Desktop/users.txt

mkdir ~/tess_tmp
cd ~/tess_tmp
SVN=svn+ssh://fluffy/usr/local/svnroot
git-svn init $SVN/tess/trunk/ --no-metadata
git config svn.authorsfile ~/Desktop/users.txt
git-svn fetch
cd ..
git clone tess_tmp tess
cd tess

Edit .git/config. Change the [remote "origin"] section to

[remote "origin"]
url = git@github.com:srveit/tess.git
fetch = +refs/heads/*:refs/remotes/origin/*
push = refs/heads/master:refs/heads/master

Then push the repo to github:

git push origin

To check out the project into a new directory:

git clone git@github.com:srveit/tess.git tess

More information on git can be found from the home page:

"See the tutorial to get started, then see Everyday Git for a useful minimum set of commands."

See this post on my site Veit Consulting.

No comments: