61

Can please somebody tell me what is wrong with this?

I run

$ 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) ...

After that $ git --version shows:

git version 1.8.2.1

It looks like git 2.x was installed but I can continue getting the old version.


Updates:

Fernando Montoya
  • 713
  • 1
  • 5
  • 6

3 Answers3

148

You need to add the Git Maintainers repository in order to get the latest Git version.

Please run these commands in order:

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

Then, check the version of the installed Git:

git --version

It's not always necessary to remove the existing Git before upgrading it, but if you run into any problems, do the following and then repeat the steps mentioned above:

sudo apt-get remove git
aalaap
  • 418
mertyildiran
  • 1,966
4

You have a second copy of git installed in /usr/local/bin which is being used instead of the system installed git.

Without knowing how the other git has been installed, I would say that you need to manually remove the other git binary from /usr/local/bin.

d a i s y
  • 5,551
Ressu
  • 14,086
0

The add-apt-repository solution didn't work for me (lots of moaning about ssl certificates). Instead I managed to get it updated by installing a backport:

Work out what release and architecture you need

lsb_release -a and uname -m will reveal the name of the release and the architecture. Mine were bionic (18.04) and amd64 (aka "x86_64")

Download the new package for that combination

I found the exact files I needed on launchpad by drilling down to those parameters from

https://launchpad.net/~git-core

to

https://launchpad.net/~git-core/+archive/ubuntu/candidate/+build/28694527 launchpad page for git on bionic amd64

Install the dependencies

dpkg -I git_2.46.0-0ppa1~ubuntu18.04.1_amd64.deb will reveal what the dependencies are. Or you can just run the install and it will tell you.

I had to install libpcre-2-8-0 which, fortunately, I could do in the standard way: sudo apt install libpcre2-8-0

Git requires the manual page, which is in a separate package "git-man" so download and install that first.

dpkg -i git-man_2.46.0-0ppa1~ubuntu18.04.1_amd64.deb

Install the git package

dpkg -i git_2.46.0-0ppa1~ubuntu18.04.1_amd64.deb

Thus I have managed to move from git 2.17 to 2.46

John Mee
  • 1,053