Convenient Ways to Install



To install Git from the Source is generally useful, because you’ll get the most recent version. Each version of Git tends to include useful UI enhancements.

Getting the latest version is often the best route if you feel comfortable compiling software from source. It is also the case that many Linux distributions contain very old packages; so unless you’re on a very up-to-date distro or are using backports, installing from source may be the best bet.

$ yum install curl-devel expat-devel gettext-devel \
openssl-devel zlib-devel
$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \
libz-dev libssl-dev

When you have all the necessary dependencies, you can go ahead and grab the latest snapshot from the Git web site:

Then, compile and install:

$ tar -zxf git-
$ cd git-
$ make prefix=/usr/local all
$ sudo make prefix=/usr/local install

After this is done, you can also get Git via Git itself for updates:

$ git clone git://

If you want to install Git on Linux via a binary installer, you can generally do so through the basic package-management tool that comes with your distribution. If you’re on Fedora, you can use yum:

$ yum install git-core

Or if you’re on a Debian-based distribution like Ubuntu, try apt-get:

$ apt-get install git

There are two easy ways to install Git on a Mac. The easiest is to use the graphical Git installer, which you can download from the Google Code page.

The most common way to install Git is via MacPorts If you have MacPorts installed, install Git via:

$ sudo port install git-core +svn +doc +bash_completion +gitweb

Installing Git on Windows is very easy. The msysGit project has one of the easier installation procedures. Simply download the installer exe file from the Google Code page, and run it:

After it’s installed, you have both a command-line version (including an SSH client that will come in handy later) and the standard GUI.

Note on Windows usage: you should use Git with the provided msysGit shell (Unix style), it allows to use the complex lines of command given in this book. If you need, for some reason, to use the native Windows shell / command line console, you have to use double quotes instead of simple quotes (for parameters with spaces in them) and you must quote the parameters ending with the circumflex accent (^) if they are last on the line, as it is a continuation symbol in Windows.

Homebrew: "the missing package manager for OSX"

Homebrew installs everything you need that Apple didn't, and it's all git and ruby underneath. It compliments OSX, and you can install GIT, your GEMS and all the GEM depedencies with 'brew'. It allows you to easily install hundreds of open-source tools, did I mention that it also installs Git?

ruby -e "$(curl -fsSL"

Run the command, and follow the instructions when prompted. Note that Terminal does not provide visual feedback when you type your password. Just type it slowly and press return. Once the installation is successful, run the following command:

$ brew doctor

If you get 'Your system is raring to brew', you can move on to the next step.

If you get warning:
'Experimental support for using Xcode without the "Command Line Tools",
you probably upgraded from Lion to Mountain Lion but haven't reinstalled the Command Line Tools.

If you get Error:
No such file or directory - /usr/local/Cellar,
run the following command, which creates the /usr/local/Cellar directory:

$ sudo mkdir /usr/local/Cellar

'sudo' allows you to run commands as a user with higher access rights, which is why it prompts you for your password, and 'mkdir' stands for “make directory”. Next, run the command below, which makes you the owner of the /usr/local directory, in addition to all nested directories. This is needed in order to install Git in the next step. Otherwise, you might get the following error when trying to install Git or other tools with Homebrew: 'Cannot write to /usr/local/Cellar'.

$ sudo chown -R `whoami` /usr/local

'chown' stands for “change owner”, the -R flag applies this to all nested files and directories, and 'whoami' is a variable that represents your OS X username. You should copy and paste the command above as is. You can learn more about any Unix commany by typing 'man' (for "manual"), followed by the command. For example:

$ man chown

If a manual is longer than a page long, it will display 'a :' at the end to signify there is more to read. To display one additional line at a time, press return. To display an additional page at a time, press the space bar. To quit at any time, press q. Then run 'brew doctor' again. If you get 'Your system is raring to brew', you are golden. If you're on Lion, you might get an error message, warning you that your "Xcode is configured with an invalid path...." The following command should fix it:

$ sudo xcode-select -switch /Applications/

Run brew doctor to verify. Your system should be raring to brew now!