Git on Ubuntu

Disclaimer: Most of the steps are copy-pastable. ;)

Git! Git! Git! The more I use it, the more I love it.

If you are reading this, I will assume that you know what Git is and for what it is used.

I will be telling very briefly, how I use the latest stable version of Git to make most out of it, for example, git-subtree.

Installing Git

I will be covering the installation for Ubuntu 12.04 but it should work on any linux distro. Like most the things, you can choose to install it via apt-get but as you might be aware of, it will give you an oooooooold version.

To get the lastest and the best, let's build from source.

  1. First quickly update the packages.

    apt-get update

  2. And now install the dependencies.

    sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential

  3. Download the version you want from Google code page. I will download 1.8.4.2 as it is latest stable at the time of writing this article.

    wget https://git-core.googlecode.com/files/git-1.8.4.2.tar.gz

  4. Now, extract the tarball you jusy downloaded. (I know remembering these nifty flags is always a pain, so Ctrl+C and Ctrl+V it.)

    tar -zxf git-1.8.4.2.tar.gz

  5. Go into the extracted folder.

    cd git-1.8.4.2

  6. Now install it.

    make prefix=/usr/local all

    sudo make prefix=/usr/local install

  7. Done! If you ever need to update it in future, use the Git itself to do it.

    git clone git://git.kernel.org/pub/scm/git/git.git

Setting It Up

Once I install it on a new machine, I set the global user details right away.

git config --global user.name "YourName"

git config --global user.email you@example.com

comments powered by Disqus