Gabriel Saldaña's blog

personal blog, photography and programming

How to install latest Git on Ubuntu

Git Logo

Git is a distributed version control system. I won’t go into much details of what Git is or why use Git instead of other VC systems. There’s plenty other sites where to check that information.

I love Git, but there’s a slight problem with Ubuntu’s repositories (feisty, gutsy): its an old version.

Git’s version on the repositories is 1.5.2.5. Its an old version and it lacks many of the new cool features like git stash and git citool and many others. So to get the latest version with all the cool features, you have to compile from source.

To do that, you will need the following packages:

First install the all the basic tools for compiling source:

sudo aptitude build-essential


sudo aptitude install libc6 libcurl3-gnutls libexpat1 zlib1g perl-modules liberror-perl libdigest-sha1-perl cpio openssh patch
gettext curl tk8.4 tcl8.4

Download the tarball from http://git.or.cz and uncompress it.

$ tar xvzf git*.tar.gz

Then, run the compilation steps and install:

$ ./configure
$ make
$ sudo make install

And there it is! Run the following to check your version.

$ git --version

The only thing that I still don’t know how to get is git command autocomplete on bash. If you install from repositories, then install from source, you’ll have it all.

About the author

Gabriel Saldaña Gabriel Saldaña is a web developer, photographer and free software advocate. Connect with him on and Twitter

Posted Under
Tagged

Post navigation

3 thoughts on “How to install latest Git on Ubuntu

  1. Gunnar says:

    Man, if you are using a distribution… Do yourself a favor, and don’t install unstructuredly your software in /usr/local/ – That will only kill your distribution’s upgradeability, and will surely bring tears to your face sooner or later. It’s way better to create updated packages based on the existing tarballs. Maybe just to rebuild Ubuntu Hardy’s (or Debian Sid’s) package (currently, both are at 1.5.4.3 while Git upstream version is 1.5.4.4 – not so far behind, are they?) will be enough. And your system will be much saner.

  2. Another option could be passing the flag ./configure –prefix=/opt/ and install compiled software there. But I don’t have much experience with that.

    Yes Debian’s packages are more up to date than Ubuntu’s (strange). I tried contacting the Ubuntu’s git package maintainer to see if I could help updating it, but I had no response.

    Can you point me to any info on how to rebuild Debian packages?

  3. Gunnar says:

    Install the dpkg-dev package – It contains the base tools for building Debian packages. One of them, the core tool several helpers/wrappers use for building packages. You will probably also want fakeroot and devscripts, to start with.
    To download the source package (that is, the .orig.tar.gz, .diff.gz and .dsc files), do:
    $ apt-get source git-core
    Now, building git will probably require you to install some dependencies – Go ahead (as root):
    # apt-get build-dep git-core
    Now just enter the directory and build the package:
    $ cd git-core-1.5.4.3
    $ dpkg-buildpacakge -rfakeroot -tc -us -uc
    Drink some coffee, and you will have a shiny new set of git-core .deb packages 🙂 I often prefer running debuild instead of dpkg-buildpackage as it adds some sugar, but it’s basically the same thing. And, of course, later on you will want to play with VCS-based package building, i.e. svn-buildpackage, git-buildpackage and the like.
    Oh, and BTW: The most _common_ situation is that Debian has more recent versions than Ubuntu – Of course, in unstable. That’s where Ubuntu pulls from.

Comments are closed.

%d bloggers like this: