I have installed git through apt-get on debian 7 which gives me:

# git --version
git version

I would like to ugrade to the latests version of git. I have tried:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

But that gives the following errors:

Fetched 6,944 B in 0s (10.1 kB/s)
W: Failed to fetch http://ppa.launchpad.net/git-core/ppa/ubuntu/dists/wheezy/main/source/Sources  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/git-core/ppa/ubuntu/dists/wheezy/main/binary-amd64/Packages  404  Not Found

I have also tried to follow this guide:


but I still cannot get the latest git, any suggestions?

  • 1
    Why not compile from source (the INSTALL document has some help on that, if you're new to it)? – nerdwaller Sep 12 '13 at 21:35
  • I would download the archive directly for the got website if the launchpad source is broken. – Ramhound Sep 12 '13 at 22:11
  • 2
    Do you really need to? In most cases, installing a newer version is not worth the trouble. Is there a particular feature in the new version that you need? Which version do you have and which one do you want to install? Anyway, you can't use PPAs with Debian, they are an Ubuntu thing. – terdon Sep 12 '13 at 22:12

Updated 2016-07-27: a wheezy-backports is now available for Git 1.9.1. Instructions still applies to install a more recent version or for Jessie.

When a newer version of a backport package isn't available, you have two options:

  1. Ask the package maintainers to prepare a backport. It's not guaranteed to work but some maintainers are positive about making backports, so I'd just try.

    The maintainers' e-mails could be found there.

  2. Build it yourself from the sources. This could be done two ways:

    • Build "as is" from the source tarball. Should you pick this route, be sure to configure the Git's build system to install everything under ~/git or /opt/git or something like this otherwise later you'll have a great PITA removing what you installed.

      The problem is that the conventional Unix way of installing software by spreading it across the whole filesystem is sensible but only when you have some sort of registry which "knows" which file belongs to which package and vice-versa, and packaging systems such as Debian's do exactly this. If you do "normal" install of a package built from the sources, you in most cases will have no way to uninstall this piece of software later (short of using checkinstall instead of make install, but this really is a last resort). Conversely, if you configure a source package to install everything under a single directory, you will have minor difficulties running the software (its "binary" directories won't be on your $PATH), in exchange uninstalling it later will be a no-brainer — a single rm -rf /path/to/that/dir.

    • Do backporting yourself. This is more involved but in simple cases it might just work so IMO it worth trying.

      Basically you go like this (a link to the .dsc file is taken from the package's page in unstable):

      # apt-get install devscripts
      $ mkdir ~/devel && cd $_
      $ dget http://ftp.de.debian.org/debian/pool/main/g/git/git_2.1.4-2.1.dsc
      $ dpkg-source -x git_2.1.4-2.1.dsc
      $ cd git

      Check if you have all the build dependencies satisfied by running:

      $ dpkg-checkbuilddeps

      And install everything that tool says is presently missing. Sometimes a package might refer to a version of something too fresh to be available in the distro you're backporting to; in this case it's okay to try to cheat and fix the version of such a package in the debian/control file.

      Now fix up the version of the packages about to be built. The best way to achieve this is to have a tool do the right thing:

      $ dch --bpo

      It will add an entry to the debian/changelog file and open your text editor of choice to oversee it. Just close the editor — the version for the packages to be built is taken from the top entry in this file.

      Now let's actually attempt to build:

      $ dpkg-buildpackage -uc -us -b

      If you're lucky, at this point you'll have a bunch of shiny new Git .deb packages in .., which you can just install using dpkg -i <packagename> ....

      (Run debuild clean to get rid of the built crud or just remove the git directory completely. You might also want to remove whatever you installed after running dpkg-checkbuilddep.)

      Unfortunately, if building fails for some reason, it takes certain knowledge to attempt to fix but this is out of scope of this discussion.

  • @Dereckson, thanks for your edit suggestion -- I appreciate it! But can you elaborate on why dget is not needed? Its whole point is to bring you all the files constituting the source package so you actually have something to unpack, tweak and build. Fetching only the single .dsc file will do just that but the source and debianization tarballs will be missing. – kostix Jul 27 '16 at 16:56
  • Oh, my fault. The sequence of command tricked me, as only git_2.1.4-2.1.dsc file is used afterwards explicitly as argument. I thought dpkg-source fetched the sources, but it indeed requires packages files to be physically there. – Dereckson Jul 27 '16 at 17:48

You can still use the Git PPA for Ubuntu Precise by telling apt to build from the latest source it finds there. The distributions are similar enough that this should work just fine.

I used it with success on Raspbian (which is based on wheezy) to get packages for armhf, but it should work for any architecture.

First add the GPG key for the PPA:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E1DF1F24

Add the URL for the source packages to apt:

cat > /etc/apt/sources.list.d/git.list << EOF
deb-src http://ppa.launchpad.net/git-core/ppa/ubuntu precise main

Update apt:

apt-get update

Install build dependencies:

apt-get build-dep git

Download and build git from source. You may want to do this is a temporary directory, as the build process creates a bit of cruft:

apt-get -b source git

Install the package you just built and clean up (git-core is no longer needed):

dpkg -i git_*.deb git-man_*.deb
dpkg -P git-core

If you want to upgrade a specific package in Debian 7 (Wheezy), you have the option to use backports by simply adding to your /etc/apt/sources.list the following lines:

deb http://cloudfront.debian.net/debian wheezy-backports main
deb-src http://cloudfront.debian.net/debian wheezy-backports main

Then, for installing/upgrading git, run the commands:

$ aptitude update
$ aptitude -t wheezy-backports install git

You can also configure backports in a separate file in /etc/apt/sources.list.d/. I particularly prefer using a /etc/apt/sources.list.d/backports.list file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.