When you want to use git on Debian its as easy as “apt-get install git-core”…… or is it? The version on the stable debian repositories (1.4.4) is very old. It lacks many of the features git users use on a regular basis. So how do you upgrade git? Well the simplest approach for getting the most recent version, for those that know how, is to wget the source, unpack, cd, configure, make, and make install. Takes about 5 minutes, and you’re up and running. But what if you don’t know how to compile, or you want to maintain package only install for your system, so upgrading and uninstalling will be easy? Where do you find a newer package?
Well, the testing and unstable repositories require you to update nearly your entire system, which is not ideal for just one package. But thanks to the clever maintainers, a backports repository has just what we need. ssh into your host, and make sure you have sudo access. The following instructions require root access.
Start by adding a new source to your apt-get sources. Open up /etc/apt/source.list as root, and add the following line:
deb ftp://ftp.nz.debian.org/backports etch-backports main contrib non-free
Next, we’ll install the keyring needed to install software from this server
sudo apt-get install debian-backports-keyring
Once this is done, we need to clear some space for the update command to work properly.
sudo apt-get clean
And then we can pull the information of new sources
sudo apt-get update
If the update command doesn’t work (you get warnings like ‘Dynamic MMap ran out of room’), refer to this forum post. Keep increasing the cache limit by 100,000 until it works).
Before we install, make sure you dont have a previous version (it could cause problems). Uninstall Git by running
sudo apt-get remove git-core git-svn git-doc
And you’re set to install. Because backports are disabled by default, we need to pass apt-get the -t option, to specifiy where to get it from.
sudo apt-get -t etch-backports install git-core git-svn git-doc
And once again, clean the tmp directory of apt-get leftovers, so you dont get disk full problems
sudo apt-get clean
Now, if you run ‘git –version’, you should see you have Git 1.5.6 installed. It’s not the most recent version, but its certainly better than 1.4.4. Now you can enjoy all the new features of Git.