My Profile Photo


I'm Jason, a web applications developer in the San Francisco Bay area.

Tracking Changes using Git

Git is a free distributed revision control system. A revision control system allows developers to submit additions or modifications they make to a software project to a central database known as a repository. Each change made to the source code for the project is known as a commit. With each commit a developer will include a comment which describes what the change is.

Unlike other popular revision control systems, such as Subversion, Git allows the developer to make multiple commits to a local repository hosted from their local computer. Once they are ready to share their changes with other developers, they will push the one or many commits they've made locally to the remotely hosted repository. When a developer begins a session of modifying a project, they'll usually run a command to 'pull' all of the latest changes made by other developers to their own local repository. This ensures that changes made by other developers do not conflict with the changes they are about to make.

Setting up an SSH Key on your Local Machine

Checking for Existing Keys

First check to see if you have SSH keys setup on your machine.

$ cd ~/.ssh
-bash: cd: /Users/johnsmith/.ssh: No such file or directory

If the directory does exist, run 'ls' to see if there is an id_rsa (or id_dsa) and (or file present. If so, you already have an SSH key pair setup to with the Git repository.

If it is indicated that the directory doesn't exist, you do not have SSH keys setup for your user account on your computer yet. Proceed with these instructions to generate SSH keys below.

Generating SSH Keys

Run the following command to generate the SSH keys.

ssh-keygen -t rsa -C ""

When asked for a passphrase, you can provide one, but it's not required. Using a passphrase with your SSH key only makes authentication more secure, and makes it so you have to provide the passphrase each time you connect to a remote server using the key. Other options include the use of a mechanism which provides the password for you when using the SSH keys, such as the keychain provided by Mac OS X.

Setting up a Remote Repository

For the purposes of this article I will assume that you are using a server running the Ubuntu operating system, a popular Linux distribution used for both desktop and server machines. I highly recommend using a Linode VPS with Ubuntu installed.

We'll be using a program known as Gitosis to setup the Git repository that you'll be hosting from the server to keep track of changes made to your application. The first step in accomplishing this is to install Git on your Ubuntu server. This is done using the apt-get package manager which is available from the Ubuntu command line.

sudo apt-get install git-core

Next we'll need to download Gitosis, the program which is going to aid in the setup and management of the repositories hosted from the server.

cd ~
git clone git://

This will place a folder named 'gitosis' inside of your home directory. Now move this directory to the /usr/local directory where software not provided by apt-get is typically installed.

sudo mv gitosis/ /usr/local

Next go into the /usr/local/gitosis folder, install Python using apt-get, and then run the script as a super user (using sudo) inside of the folder to complete the installation.

cd /usr/local/gitosis
sudo apt-get install python-setuptools
sudo python install

Now that Gitosis is installed, the next step is to create a user account on the Ubuntu server which will host the repository for the project, as well as other repositories you choose to add in the future. Run the following command to add the 'git' user which will exist on the server without a password (so no one can login as the 'git' user), with it's home directory specified as /var/git (a proper place for the repositories to be hosted from the system).

sudo adduser -system -shell /bin/sh -gecos 'git version control' -group -disabled-password -home /var/git git