How to Install and Get Up and Running Quickly with GIT – a Fast, Distributed Version Control System.

Git LogoI have recently installed and used Git for the first time and I have been impressed by its excellent modular and distributed design, speed, efficiency and usefulness.  So what is Git?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.  It may be used as a source control management system by software developers.  However, it has a much wider remit and may be used as a version control system for all documents, spreadsheets, presentations and so on.

For some people approaching Git for the first time, it may appear somewhat daunting and overwhelming – not sure where to start, and then how to proceed once on the journey. Thus, the purpose of this article is to provide concise tips and references to facilitate you to get up and running quickly with Git.

Benefits of Version Control

Before jumping into the technical details, I want to briefly outline some of the benefits of a Version Control System (VCS).  They include:

  • Providing snapshots of your documents and the ability to easily go back to an earlier version/revision of your work.
  • Facilitating an efficient and well managed organisation of documents. Experienced document authors compensate for not having a document management system by developing their own naming conventions for each document revision.  As a result, their Documents folder is littered with many revisions of documents using specialized file naming conventions such as file name – date – revision.ext.  A version control system replaces this chaos with a well structured consistent, reliable, efficient and easily managed organisational structure that allows you to focus on the work at hand – the content of your documents.
  • Provides accountability – the ability to maintain and search what was edited when and by whom and what they did.  This is of particular importance when working in a team or collaborating with external members.
  • Adapting to use whatever workflow is appropriate for your project – centralised, distributed, Gatekeeper, and so on.
  • A real time-line of effort put in to complete a project – helps in estimating new projects and billing complete ones.
  • Provision of a backup service (if using a remotely hosted source control solution).
  • Parking projects and then taking them up months/years later and jumping right in by reviewing your comments on what you already did up to the point where you left off.
  • Take risks and make changes knowing that you can always restore a project to a point in time.
  • The ability to create new “branch”  versions. This feature can be useful for making bug fixes when projects have already been released to the field and the next build of the project is in development.
  • Branching also facilitates parallel development. If several people are working on the same project, an integration branch can be created. When any party has new working code, it can be merged to the integration branch where all parties can use the change.
  • Conserving disk space – The VCS only stores the latest version of a file and the differences between each version that precedes it.  Thus the disk space required is usually several orders of magnitudes smaller than what would be required with a VCS.

Install Git and Get up and Running Quickly

  1. If you are new to version control, it is highly recommended you familiarize yourself with the concepts.  An excellent visual introductory guide to version control is available online.
  2. To Install Git on Windows:
    1. There are several different Git installation packages available for installation on Windows.
      I recommend you download and install GitExtensions (which includes MSysGit and KDiff3).  It has the following features:

      • Windows Explorer integration for Git.
      • Visual Studio (2005,2008,2010) plugin for Git.
      • Can be integrated with the Eclipse IDE.
      • Feature rich user interface for Git.
      • Single installer installs Git (MSysGit), GitExtensions, Putty and the merge tool KDiff3.
      • 32bit and 64bit support.
    2. A step-by-step screenshot analysis of each stage of the installation process is available.  In essence, accept the default settings at each stage.
    3. Note: I suggest one change to the default settings:
      When prompted to Adjust your path environment during the Git installation, I recommend selecting:
      Run Git from the Windows Command Prompt

      This will simply allow you to run Git from the command prompt regardless of your current working folder.
  3. To install Git on Ubuntu Linux:
    1. The version installed by apt-get is quite old.  There are simple instructions available to install the latest current stable version here. I recommend installing git-core, git-doc, gitk and git-gui.
  4. To Create a New Repository using the graphical user interface:
    1. Run Git Gui.
    2. Create a new Repository and choose a project folder.
    3. Select everything under Unstaged Changes.
    4. From the MenuBar, Select Commit | Stage to Commit
    5. In the box on the bottom-right of Git Gui, labeled Initial Commit Message, Enter the commit message.
      • The message may include such details as:
        Name_of_commiter: Joe Bloggs
        Date: 01-01-2000
        Version: 00.01.00
        Description of Changed made:  Several line description.
    6. Select the commit button beside bottom window.
  5. To Create a New Repository using the command line:
    It is even easier to create a new repository from the command line.

    1. Open up a command prompt (windows) or terminal (Linux) and change directory to the project folder. Then enter the following commands:
      1. To create the new repository:
        git init
      2. To add all the contents of the folder into the Git repository:
        git add .
      3. Finally, to commit the files to the repository:
        git commit -m “InitialisedRepository”
  6. To Configure the Eclipse IDE to use Git Gui as an embedded version control management tool:
    There are two excellent and short video tutorials on Youtube to demonstrate this.

    1. Using Git GUI with Eclipse Part I – Setting up the workspace
    2. Using Git GUI with Eclipse Part II – Pushing changes to the server

    Indeed, the method outlined in the videos may be used to integrate Git Gui with any software application that supports external tool configuration and invocation.

Online Resources to help you on your way

  1. Some excellent online resources for learning and using Git:
    • ProGit – An excellent resource for someone new to Git.
  2. Some excellent video screencasts explaining how to use Git:

Git Tips

  1. To configure Git to use an Internet Proxy:
    If your computer passes through a Proxy in order to access the Internet, then Git must be configured to use this Proxy when interacting with repositories on the Internet.  The command to enable Git to use a Proxy is:
    git config –global http.proxy http://our-proxy-server:8088
  2. To configure Git to ignore certain file types:
    Git may be configured to ignore certain filetypes by placing entries in the GIT_DIR/info/exclude file located in the project folder.
    Note: This file must be ready before any files are committed to the Git repository (i.e.: immediately after git init).

    1. The entries may be as follows:
    2. For more information, refer to the relevant chapter in the online Git Community Book.
  3. To checkout just one or two files from an older version to be included in the current version:
    Occasionally it may be necessary to check out an old version of just one file and include it in the current working branch (as opposed to checking out the entire older branch just to get that one particular file)  The instructions are in the Git User manual.
  4. To setup your own Git Host Repository:
    There is an excellent guide online explaining step-by-step how to setup a (simple) new remote online repository.
    The steps detailing how to setup a more advanced GIT host repository with automatic user management on a Ubuntu server with clients connecting from Windows are available here.

To access (push, pull and fetch) a GitHub repository from behind a proxy.

The original reference for these instruction are available here.

The typical scenario behind a proxy is:

  • All internet access passes through a proxy.
  • The proxy allows outward connections of type HTTP and HTTPS only (ports 80 and 443 respectively).
  • The CONNECT method is only enabled for port 443.
  • Optionally, proxy authentication is required.

Windows Platform

  1. Install GitExtensions (as described earlier).
  2. Generate your SSH key if you have not already done so and add it to your GitHub account (instructions are available online).  It is also highly recommended you generate a passphrase from reasons outlined here.
    Note: Using Git Gui you may generate your SSH key and  passphrase very easily from the menu bar by selecting Help | Show SSH Key | Generate Key.
  3. Download the utility connect which permits the tunneling of various network connectinos via HTTP(S) proxies.
    The source code connect.c is available for download and compilation.  A pre-compiled binary for windows users is available.
    I placed connect.exe in  C:\software\connect\connect.exe
  4. Backup your existing SSH config file (if it exists).
  5. Create a new SSH config file called config-proxy and place the following text in that file.
    (Note: the text from ProxyCommand to %p should be on one line with a space after “-H”).ProxyCommand C:/software/connect/connect.exe -H %h %p
    User git
    Port 22
    IdentityFile “C:\Users\username\.ssh\id.rsa”
    TCPKeepAlive yes
    IdentitiesOnly yes

    User git
    Port 443
    IdentityFile “C:\Users\username\.ssh\id.rsa”
    TCPKeepAlive yes
    IdentitiesOnly yes

  6. Finally, when connecting to your Github repository, specify the remote location as follows (replacing the uppercase words to the appropriate values corresponding to your details):
    For example, to clone an existing project:
    git clone ssh://
  7. That’s it!

Google Tech Talks

  • What is Git – A talk by Randal Schwartz.  He presents a good technical overview of Git.
  • Linus Torvalds, the creator of Git, visited Google to share his thoughts on the source control management system. This high-level talk highlights the differences between Git and the alternative version control systems and is quite entertaining as Linus as some strong views on technical matters and design philosophies

One comment on “How to Install and Get Up and Running Quickly with GIT – a Fast, Distributed Version Control System.

  1. […] more information on git, check out the Pro Git book. The Seeker’s Quill has a good post on using git. There’s also a blog series on lostechies that I found […]

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s