Moving from Subversion to Git

I just finished moving my files from Subversion to Git. Git is a distributed version control first built by Linus Torvalds and has matured a lot since its first creation. It is currently used by a number of important open source projects including the Linux kernel, Perl, Wine and Ruby on Rails. I chose to move to Git for a number of reasons:

  1. Distributed: So I can make commits even if I’m not online and have a complete history of changes.
  2. Easy branching and merging: I found myself keeping a ‘scratch’ folder in Subversion and only transfer changes to a working copy once I had finished all my changes. I feel that this defeats the purpose of having version control. Git supports easy branching so I can make experimental branches (which have their own histories) and then merge them back into the main branch when I’m ready.
  3. Normal commands like mv, cp, rm can be used as Git doesn’t track files individually.
  4. Interacts with SVN: I’ll need to use Subversion for my school projects, but I can have a personal Git repository where I make regular commits and only push to the team’s Subversion repo when nothing is broken.
  5. All the cool kids are using it.

I have two subversion repos: one for my code and one for other documents. The move from Subversion to Git was actually quite smooth. My repositories currently live on my old G4 Powermac, so I decided to do the transition on that machine itself (though I didn’t need to due to Git’s distributed nature). I had found a quick tutorial which I followed to do the actual move from a Subversion repo to a Git repo. I then did a quick git clone as follows on my laptop and desktop:

git clone ssh://domain.com/path/to/repo/

I could have used the simple Git server instead of SSH, but since I would be doing regular pulls and pushes (updates and upstream commits), I decided to just use SSH uniformly. Since then I’ve made changes to my Source repo and it has synced properly to my desktop. I ran into a problem where one of the git commands could not be executed on the remote machine. This turned out to be a problem with SSH on OS X, where the path for the non-interactive shell started by Git didn’t have the proper path. I didn’t research it very much because it turned out that the adding the following line to my ~/.bashrc solved the problem.

PATH = $PATH:/usr/local/git/bin

This adds the git path to the users path and lets the clone run properly.

The only disadvantage is that I have do a commit to my local repo and then push it to the repo on my server. However it’s still a simple process. Whenever I make a change I want to save I do a simple

git commit -a

and enter an appropriate message. Then before I leave my computer for a long time I do a

git push origin

which synchronizes all my local branches with those on the server. A simple git pull suffices to update the local repo.

I haven’t had a chance to use this system fully yet as I haven’t done much moving about. But classes start tomorrow so I hope to have a chance to use my new system properly. In particular I plan to make use of the easy branching and the SVN integration. My college’s lab machines don’t currently have Git installed on them, but I’m going to request to have Git installed. From what I’ve seen of the faculty, this shouldn’t be hard to accomplish. Here’s looking forward to the rest of the year using Git to boost my programming productivity.

Advertisements

Published by

Shrutarshi Basu

Programmer, writer and engineer, currently working out of Cornell University in Ithaca, New York.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s