Friday, January 9, 2009

Git as my New SCM Solution

As a developer in collaborative environments, I am used to relying on source control management systems [1]. In different companies, I worked with CVS [1], ClearCase [1], and subversion [2]. For my side projects (personal ones and ones related to my social involvements), I was a big fan of subversion.

But subversion has limitations, like the importance of the connectivity with the subversion server whenever you want to gain access a file history or to revert an update. Because I have just started a new side project [3], I have decided to go with git and the hosting service github [4].

I am going to describe the straightforward steps to setup, connect, and get working with git/github.

First thing: install git runtime. git has been developed in replacement to a tools used to manage linux kernel code. It has been preliminary built on linux. For Windows users, you can install it over cygwin or use a fork built over MSys. I am setup with msysgit [5].

The authentication mechanism on git repositories relies on SSH [6]. When creating an account on github, a public key is asked. Then anytime, the git runtime on your machine operates with the github server, it signs commands with your private key, and your public key is remotely used to verify the git runtime works on your behalf. To generate a pair of keys, just type the following command in a git bash window:

$ ssh-keygen -C "" -t rsa

In order to use git on another machine, you have to copy over the generated SSH file (id_rsa and, from %USERDIR%/.ssh). To backup them, I suggest two services I mentioned in my list 2009 Products I Cannot Live Without: KeePass (as a personal encrypted repository) and DropBox (as the replicator from the cloud).

The first time, it is easier to use github website to create an initial repository. You can verify that your SSH key is correctly configure.

$ ssh

I have created the project diku-dilenga. If the SSH key is recognized, you can ready to clone (checkout equivalent for subversion) any project you have access to, like mine:

$ git clone git://

Adding file in your own project is easy. Note that the add is recursive (so adding . (dot) from the root folder will add all files for the next commit).

$ git add doc/README

Persisting an addition or an update is simply done with the following command. Note that giving a meaningful comment or a project task identifier is highly recommended ;)

$ git commit -a -m "..."

For additional commands (to remove files, to create branches, to merge branches, etc.), you have to refer to reference sites like:

Once all additions, updates, and removal have been locally done, updating the remote server (github in my case), is fairly simple:

$ git push

Getting updates made by others, or from another computer, are also very simple:

$ git pull

Update 2009/01/13:
This post is now part of the series Web Application on Resources in the Cloud.
I recommend you read the introduction of my side project which is going to be visible on

Update 2009/01/15:
An illustrated guide to git on Windows [7] has been published on github website. I am not a big fan of complex graphical user interfaces (GUIs) where end-users loose the focus of their current task! I think pushing/pulling are relatively rare operations (compared to commit/revert/history) and should have a very light interface... My two cents

Update 2009/03/24:
Thanks to some follower's feedback, it appears that dealing with Git commands is still fuzzy. Here is aSequence diagram initially produced by Olivier Steele and described on git ready blog.

A+, Dom
  1. Source Control Management description, CVS and ClearCase histories on Wikipedia.
  2. subversion is a popular cross platforms open source replacement to the aging CVS.
  3. Future posts will describe the nature of this project ;)
  4. Official git website, git history on Wikipedia, and github hosting service.
  5. Package of git for Windows: msysgit
  6. SSH network protocol and public-key cryptography principles on Wikipedia
  7. An Illustrated Guide to Git on Windows on github website.

No comments:

Post a Comment