Source Control with git

Why Source Control?

This may seem like a silly question, but there’s plenty of organizations out there that are still using no source control and take some convincing.  A few of the larger benefits include

  1. Being able to see differences between old and new versions of code
  2. Able to roll back code to an earlier state
  3. Track and audit who made specific changes
  4. Develop code in isolated branches
  5. Easily merge code from multiple users and branches

There are many more benefits to using source control but even in a solo environment the ability to track changes is undeniably the most important aspect when developing applications.

Why git?

There are many different source control systems out there but git has a few important advantages over the competition.  We will be going with git mainly due to the fact that it has very good linux support, it’s free, it’s fast and it can be easily hosted on sites such as github and bitbucket.

git is also a distributed model so we don’t always need to have access to a central server and can commit and manage branches locally.  I’ve run into the issue at work where I don’t have access to our SVN repo when remote and have started using git-svn to handle local commits.

Check out http://git-scm.com/ to learn more about git and http://stackoverflow.com/questions/871/why-is-git-better-than-subversion if you want a much more in depth look at the differences between git and other systems (don’t mind the tone of the initial question, the responses are very good read if you’d like to know more).

Installing git

Open up your terminal and run


sudo apt-get install git

Continue when prompted and let it install.

We can set your user name and email that will be used to identify your commits by running


git config --global user.name "Stephen Garlick"

git config --global user.email "sgarlick987@gmail.com"

make sure the email matches the email you plan to use for your GitHub account and finally


git config --global credential.helper cache

which will let git cache your GitHub password in memory for 15 minutes.

Next time we’ll talk about initializing our git repo and getting it up on github along with a few basic commands to get us started.