升级Ubuntu 14.04上的Git版本。

请问有人可以告诉我这是什么问题吗?
我运行
$ sudo apt-get purge git; sudo apt-get autoremove; sudo apt-get install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  git-man liberror-perl
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  git* git-core*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 21.0 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 81533 files and directories currently installed.)
Removing git-core (1:1.9.1-1ubuntu0.1) ...
Removing git (1:2.2.2-0ppa1~ubuntu10.04.1) ...
Purging configuration files for git (1:2.2.2-0ppa1~ubuntu10.04.1) ...
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  git-man liberror-perl
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 1,831 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 80929 files and directories currently installed.)
Removing git-man (1:2.2.2-0ppa1~ubuntu10.04.1) ...
Removing liberror-perl (0.17-1.1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  git-man liberror-perl
Suggested packages:
  git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk
  gitweb git-arch git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  git git-man liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/11.0 MB of archives.
After this operation, 22.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Selecting previously unselected package liberror-perl.
(Reading database ... 80751 files and directories currently installed.)
Preparing to unpack .../liberror-perl_0.17-1.1_all.deb ...
Unpacking liberror-perl (0.17-1.1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a2.2.2-0ppa1~ubuntu10.04.1_all.deb ...
Unpacking git-man (1:2.2.2-0ppa1~ubuntu10.04.1) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.2.2-0ppa1~ubuntu10.04.1_i386.deb ...
Unpacking git (1:2.2.2-0ppa1~ubuntu10.04.1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up liberror-perl (0.17-1.1) ...
Setting up git-man (1:2.2.2-0ppa1~ubuntu10.04.1) ...
Setting up git (1:2.2.2-0ppa1~ubuntu10.04.1) ...

之后,$ git --version 显示如下:
git version 1.8.2.1

看起来已经安装了git 2.x,但我仍然无法获取旧版本。
更新:
- 我已经尝试过这个:在ubuntu 12.04上将Git 1.7.9.5升级到当前版本的GIT 2.x - dpkg -L git 参见:https://gist.github.com/montogeek/e7bedaf03cef9a3d969b - which git:/usr/local/bin/git

иҜ·зј–иҫ‘жӮЁзҡ„её–еӯҗ并添еҠ dpkg -L gitе’Ңwhich gitзҡ„иҫ“еҮәз»“жһңгҖӮ - muru
2个回答

你需要添加Git Maintainers存储库以获取最新的Git版本。
请按照以下顺序运行这些命令:
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git

然后,检查已安装的Git版本:
git --version

不一定需要在升级 Git 之前删除现有的 Git,但如果遇到任何问题,请按照以下步骤操作,然后重复上述提到的步骤:
sudo apt-get remove git

7我成功升级了,而不需要先移除git(我没有运行sudo apt-get remove git)。 - 7ochem
我认为没有必要移除git。我在升级时(从Ubuntu 14.04的版本)并没有将其移除。 - glarrain
1@glarrain 我写下这句话是为了预防任何形式的数据损坏。 - mertyildiran
1我有一个运行Ubuntu 14的企业VMware虚拟桌面,它告诉我 - 无法添加ppa,请检查格式... - Kalpesh Soni
我在Windows 10上使用Ubuntu 18.04 LTS(使用Windows子系统来运行Linux)。这种方法在其中也完美地工作。截至目前(2020年3月),我使用的是Git v2.25.1。 - Manu Manjunath

你在 /usr/local/bin 目录下安装了另一个 git 的副本,而这个副本正在被使用,而不是系统安装的 git。
由于我不知道另一个 git 是如何安装的,我建议你手动从 /usr/local/bin 目录中删除另一个 git 可执行文件。