How can I update to a newer version of Git using apt-get?

I’ve just set up a new machine with Ubuntu Oneiric 11.10 and then run

apt-get update
apt-get upgrade
apt-get install git

Now if I run git --version it tells me I have git version but on my local machine I have the much newer git version

I know I can install from source to get the newest version, but I thought that it was a good idea to use the package manager as much as possible to keep everything standardized.

So is it possible to use apt-get to get a newer version of git, and what is the right way to do it?

Asked By: cwd


You have several options:

  1. Either wait until the version you need is present in the repository you use.
  2. Compile your own version and create a deb.
  3. Find a repository that provides the version you need for your version of your distribution(e.g. Git PPA).
  4. If you don’t need any particular feature from the newer version, stay with the old one.

If a newer version is available in the repositories you use, then apt-get update && apt-get upgrade (as root) updates to the latest available version.

For those who don’t know what a PPA is, link

Answered By: Marco

Doing a search for “git ppa” gives Git stable releases. See instructions for installing here. You can also install the package by downloading directly from the web page, and installing with dpkg -i.

Answered By: Faheem Mitha

Here are the commands you need to run, if you just want to get it done:

sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-key adv --recv-keys --keyserver A1715D88E1DF1F24 40976EAF437D05B5 3B4FE6ACC0B21F32 A6616109451BBBF2
sudo apt-get update
sudo apt-get install git -y
git --version

As of Dec 2018, I got git 2.20.1 that way, while the version in the Ubuntu Xenial repositories was 2.7.4.

If your system doesn’t have add-apt-repository, you can install it via:

sudo apt-get install python-software-properties software-properties-common
Answered By: Dan Dascalescu

To update git on Ubuntu 12.04 just follow this line of commands:

sudo apt-get install python-software-properties
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git -y
git --version
Answered By: alabi temitope

You can do this by homebrew in the easiest way:

install homebrew:

/usr/bin/ruby -e "$(curl -fsSL"

upgrade git:

brew upgrade git
Answered By: Masih Sadri
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.