Search code examples
gitredhat

How to install latest version of git in Redhat 6.x/7.x


I am trying to install git in Redhat6. I am following how to install git this tutorial.

# cd /usr/src
# wget https://www.kernel.org/pub/software/scm/git/git-2.0.5.tar.gz
# tar xzf git-2.0.5.tar.gz

# cd git-2.0.5
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
# source /etc/bashrc

# git --version

I am able to clone the repo and able to download the git zip file. but when I execute this command.

 make prefix=/usr/local/git all

I get this error

[varun@home git-2.0.5]# make prefix=/usr/local/git all 
GIT_VERSION =2.0.5
* new build flags
CC credential-store.o /bin/sh: cc: 
command not found make: *** [credential-store.o] Error 127

How do I solve this?

I am able to install git using yum install git. but by default 1.7.1 is getting install. But i want to install above 2.

Edit 1 When I executed

yum groupinstall 'Development Tools'

It download the required dependency and the above error is gone.

Now when I execute this make prefix=/usr/local/git all I am getting bellow error

    CC bulk-checkin.o
In file included from cache.h:4,
                 from bulk-checkin.h:7,
                 from bulk-checkin.c:4:
git-compat-util.h:213:25: warning: openssl/ssl.h: No such file or directory
git-compat-util.h:214:25: warning: openssl/err.h: No such file or directory
git-compat-util.h:320:25: warning: openssl/evp.h: No such file or directory
git-compat-util.h:321:26: warning: openssl/hmac.h: No such file or directory
git-compat-util.h:323:28: warning: openssl/x509v3.h: No such file or directory
In file included from bulk-checkin.h:7,
                 from bulk-checkin.c:4:
cache.h:11:21: warning: openssl/sha.h: No such file or directory
In file included from bulk-checkin.c:5:
csum-file.h:11: error: expected specifier-qualifier-list before ‘SHA_CTX’
csum-file.h:23: error: expected specifier-qualifier-list before ‘SHA_CTX’
bulk-checkin.c:96: error: expected declaration specifiers or ‘...’ before ‘SHA_CTX’
bulk-checkin.c: In function ‘stream_to_pack’:
bulk-checkin.c:128: warning: implicit declaration of function ‘SHA1_Update’
bulk-checkin.c:128: error: ‘ctx’ undeclared (first use in this function)
bulk-checkin.c:128: error: (Each undeclared identifier is reported only once
bulk-checkin.c:128: error: for each function it appears in.)
bulk-checkin.c: In function ‘deflate_to_pack’:
bulk-checkin.c:193: error: ‘SHA_CTX’ undeclared (first use in this function)
bulk-checkin.c:193: error: expected ‘;’ before ‘ctx’
bulk-checkin.c:205: warning: implicit declaration of function ‘SHA1_Init’
bulk-checkin.c:205: error: ‘ctx’ undeclared (first use in this function)
bulk-checkin.c:222: warning: passing argument 3 of ‘stream_to_pack’ makes integer from pointer without a cast
bulk-checkin.c:95: note: expected ‘int’ but argument is of type ‘off_t *’
bulk-checkin.c:222: error: incompatible type for argument 6 of ‘stream_to_pack’
bulk-checkin.c:95: note: expected ‘const char *’ but argument is of type ‘enum object_type’
bulk-checkin.c:222: warning: passing argument 7 of ‘stream_to_pack’ makes integer from pointer without a cast
bulk-checkin.c:95: note: expected ‘unsigned int’ but argument is of type ‘const char *’
bulk-checkin.c:222: error: too many arguments to function ‘stream_to_pack’
bulk-checkin.c:237: warning: implicit declaration of function ‘SHA1_Final’
make: *** [bulk-checkin.o] Error 1

make prefix=/usr/local/git install I get this

    CC bulk-checkin.o
In file included from cache.h:4,
                 from bulk-checkin.h:7,
                 from bulk-checkin.c:4:
git-compat-util.h:213:25: warning: openssl/ssl.h: No such file or directory
git-compat-util.h:214:25: warning: openssl/err.h: No such file or directory
git-compat-util.h:320:25: warning: openssl/evp.h: No such file or directory
git-compat-util.h:321:26: warning: openssl/hmac.h: No such file or directory
git-compat-util.h:323:28: warning: openssl/x509v3.h: No such file or directory
In file included from bulk-checkin.h:7,
                 from bulk-checkin.c:4:
cache.h:11:21: warning: openssl/sha.h: No such file or directory
In file included from bulk-checkin.c:5:
csum-file.h:11: error: expected specifier-qualifier-list before ‘SHA_CTX’
csum-file.h:23: error: expected specifier-qualifier-list before ‘SHA_CTX’
bulk-checkin.c:96: error: expected declaration specifiers or ‘...’ before ‘SHA_CTX’
bulk-checkin.c: In function ‘stream_to_pack’:
bulk-checkin.c:128: warning: implicit declaration of function ‘SHA1_Update’
bulk-checkin.c:128: error: ‘ctx’ undeclared (first use in this function)
bulk-checkin.c:128: error: (Each undeclared identifier is reported only once
bulk-checkin.c:128: error: for each function it appears in.)
bulk-checkin.c: In function ‘deflate_to_pack’:
bulk-checkin.c:193: error: ‘SHA_CTX’ undeclared (first use in this function)
bulk-checkin.c:193: error: expected ‘;’ before ‘ctx’
bulk-checkin.c:205: warning: implicit declaration of function ‘SHA1_Init’
bulk-checkin.c:205: error: ‘ctx’ undeclared (first use in this function)
bulk-checkin.c:222: warning: passing argument 3 of ‘stream_to_pack’ makes integer from pointer without a cast
bulk-checkin.c:95: note: expected ‘int’ but argument is of type ‘off_t *’
bulk-checkin.c:222: error: incompatible type for argument 6 of ‘stream_to_pack’
bulk-checkin.c:95: note: expected ‘const char *’ but argument is of type ‘enum object_type’
bulk-checkin.c:222: warning: passing argument 7 of ‘stream_to_pack’ makes integer from pointer without a cast
bulk-checkin.c:95: note: expected ‘unsigned int’ but argument is of type ‘const char *’
bulk-checkin.c:222: error: too many arguments to function ‘stream_to_pack’
bulk-checkin.c:237: warning: implicit declaration of function ‘SHA1_Final’
make: *** [bulk-checkin.o] Error 1

And these two line

 # echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
 # source /etc/bashrc

are successfully executed

but when I type git --version I am still getting

bash: /usr/bin/git: No such file or directory


Solution

  • Looks like /bin/sh: cc: command not found is the error message and it has been split on 2 lines to add extra confusion. i.e. there is no cc command.

    It means that you need to install a C compiler. If you run the following command it should install all the necessary tools (gcc, binutils, etc) to compile git.

    yum groupinstall 'Development Tools'

    You are also missing the necessary development headers, like openssl:

    yum install openssl-devel curl-devel expat-devel gettext-devel zlib-devel