I downloaded git version 2.9.5 to replace my older version which is 2.7.4.

I downloaded the .gz file from: https://mirrors.edge.kernel.org/pub/software/scm/git/

Turned out as I tried installing that I was missing zlib.h header file, i installed it by issuing the following command:

sudo apt-get install libz-dev

Then I navigated to the newly unzipped git directory again and did all of the following steps:

make install

Everything went smooth and I did not run into any problems, but git --version still shows:

git version 2.7.4

Why is that the case and how to fix it?


Thanks Yaron, the problem has ALMOST been fix. the last step:

make install install-doc install-html

gives me the following error:

"ASCIIDOC git-revert.xml /bin/sh: 2: asciidoc: not found Makefile:334: recipe for target 'git-revert.xml' failed make[1]: * [git-revert.xml] Error 127 make[1]: Leaving directory '/home/omair/git-2.9.5/Documentation' Makefile:2367: recipe for target 'install-doc' failed make: * [install-doc] Error 2"

I have already, as suggested by "https://discourse.gohugo.io/t/solved-asciidoctor-asciidoc-not-found-in-path/10017/2" did these steps

sudo apt-get install asciidoctor

and when that failed,tried:

sudo gem install asciidoctor

still getting the error but the git has now been updated.

  • 1
    Let's back up a bit. Why did you specifically choose version 2.9.5? This choice is oddly specific given that the latest version is 2.17.0. In any case, for ease of installation, I would recommend using the git PPA (launchpad.net/~git-core/+archive/ubuntu/ppa) instead of installing from a tarball like you did. – edwinksl May 3 '18 at 6:38
  • 1
    I didn't know that the latest version is 2.17.0 and second I just wanna learn how to unzip and manually install in linux. – Linux Newbie May 3 '18 at 6:41
  • 1
    @edwinksl - in the link provided by the OP, the git gz binaries sort algorithm shows 2.9.5 at the end, of the list while 2.17.0 is in the middle – Yaron May 3 '18 at 6:42
  • @LinuxNewbie can you check update-alternatives --config git. – Rajesh Rajendran May 3 '18 at 7:09

It seems like you have two versions of git in your computer:

  1. Version 2.7.4 which was installed by root
    • You didn't remove the git version 2.7.4
  2. Version 2.9.5 which was installed locally by your user
    • You didn't update your path to use git 2.9.5 instead of git 2.7.4
    • You didn't install git as user root

In order to use git version 2.9.5, you can:

  1. Use the newly installed git binary:
    • Find in your home directory, the location of the new git binary
    • Update your path to find first the newly installed git 2.9.5
  2. Install git as root (see info taken from INSTALL file in git-2.17.0.tar.gz package - please review the INSTALL file in source directory of your package for more info)
           Git installation

Normally you can just do "make" followed by "make install", and that will install the git programs in your own ~/bin/ directory. If you want to do a global install, you can do

    $ make prefix=/usr all doc info ;# as yourself
    # make prefix=/usr install install-doc install-html install-info ;# as root

(or prefix=/usr/local, of course). Just like any program suite that uses $prefix, the built results have some paths encoded, which are derived from $prefix, so "make all; make prefix=/usr install" would not work.

The beginning of the Makefile documents many variables that affect the way git is built. You can override them either from the command line, or in a config.mak file.

Alternatively you can use autoconf generated ./configure script to set up install paths (via config.mak.autogen), so you can write instead

    $ make configure ;# as yourself
    $ ./configure --prefix=/usr ;# as yourself
    $ make all doc ;# as yourself
    # make install install-doc install-html;# as root
  • I repeated all the steps as "sudo", but it still shows the older version. Edit: I even deleted the older version and re-repeated all the steps and it now says: "bash: /usr/bin/git: No such file or directory " – Linux Newbie May 3 '18 at 6:40
  • @LinuxNewbie Your path is defined in a way it choose the older version of git, the simple way to use the git version you compiled is the execute ~/bin/git --version - assuming that the binary was installed there – Yaron May 3 '18 at 6:48
  • Yaron, please see the update i have made in my OP. Thanks. – Linux Newbie May 3 '18 at 7:07
  • @LinuxNewbie - did you execute the command ` make install install-doc install-html` as root? (e.g. by prefix sudo before running the command)? – Yaron May 3 '18 at 7:31
  • @LinuxNewbie what happened when you execute sudo make install at that stage? does it install git? can you use git without installing its documents? – Yaron May 3 '18 at 7:32

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.