如何在Redhat 6.x / 7.x中安装最新版本的git

时间:2015-09-22 06:02:56

标签: git redhat

我正在尝试在Redhat6中安装git。 我正在关注how to install git本教程。

# 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

我能够克隆回购并能够下载git zip文件。 但是当我执行这个命令时。

 make prefix=/usr/local/git all

我收到此错误

[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

我该如何解决这个问题?

我可以使用yum install git安装git。但默认情况下1.7.1正在安装。但我想在2以上安装。

修改1 我执行时

yum groupinstall 'Development Tools'

下载所需的依赖项,上述错误消失了。

现在,当我执行此 make prefix=/usr/local/git all 时,我收到了以下错误

    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 我明白了

    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

这两行

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

成功执行

但是当我输入git --version时,我仍在

  

bash:/ usr / bin / git:没有这样的文件或目录

2 个答案:

答案 0 :(得分:3)

看起来/bin/sh: cc: command not found是错误消息,它已被拆分为2行,以增加额外的混淆。即没有cc命令。

这意味着您需要安装C编译器。如果你运行以下命令,它应该安装所有必要的工具(gcc,binutils等)来编译git。

yum groupinstall 'Development Tools'

您还缺少必要的开发标题,例如openssl:

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

答案 1 :(得分:2)

请在下面找到我在系统上安装没有互联网访问权限的Git的步骤

  • 从您的PC /笔记本电脑https://www.kernel.org/pub/software/scm/git/下方链接下载所需的tarball。我使用的是Git-2.8,因为客户要求的版本是> = 2.7.4
  • 连接到远程Linux系统(通过winscp或nay其他远程连接工具)。并将已下载的git-[version].tar.gz文件移动到要安装'git'的linux系统上的所需位置。我把它放在目录中:/var/opt/teradata/packages/Package/GIT/
  • 从ommand提示符转到放置上述文件的目录并运行以下命令以解压缩包tar -xvzf git-2.8.0.tar.gz
  • cd进入上面的untar命令新创建的目录,例如: cd git-2.8.0/
  • 使用ls -ltr验证所有需要的文件和目录是否已解压缩到上述文件夹中。
  • 使用以下命令设置路径和前缀变量。

    PATH=$PATH:/var/opt/teradata/packages/Package/GIT/git-2.8.0/usr/bin
    PATH=$PATH:/var/opt/teradata/packages/Package/GIT/git-2.8.0
    export PATH=$PATH:/var/opt/teradata/packages/Package/GIT/git-2.8.0
    make prefix=/usr/local/git all
    echo $CC
    
  • 运行./configure以检查预安装配置检查。
  • 运行make install进行安装。
  • 使用git检查git --version是否已正确安装。