如何使用apt安装最新版本的Git?

我读到了Git中的一个安全漏洞,它已在2.2.1版中修复。 我目前在我的系统上使用Git 2.1.0(Ubuntu 14.10),并试图用apt重新安装它。 但是,apt告诉我,我目前有最新版本。

Git网站没有Linux的预建版本。 他们说你可以用包管理器安装它。 如果没有源代码构建,我将如何安装最新版本的Git?

在Ubuntu上使用git维护者的PPA :

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

如果您不知道PPA是什么,请首先阅读什么是PPA以及如何使用它们?

如果您收到有关未找到add-apt-repository命令的错误,则可能需要添加python-software-properties软件包或software-properties-common具体取决于您的Ubuntu版本。

Ubuntu 14.04

 sudo apt-get install software-properties-common 

Ubuntu 13.10或更早版本

 sudo apt-get install python-software-properties 

这就是我在Ubuntu 12.04上将git 1.7.9.5升级到2.xxx所做的:

 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 install git -y git --version