先安装:curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install curl-devel expat-develgettext-devel openssl-devel zlib-devel
下载安装包:
# wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
注:也可到git官网下载其他版本(https://mirrors.edge.kernel.org/pub/software/scm/git/)
编译安装git
# tar -zxf git-2.9.5.tar.gz
# cd git-2.9.5
# ./configure --prefix=/usr/local/git-2.9.5
# make
# make install
添加环境变量:在/etc/profile文件末尾添加如下代码
exportPATH=$PATH:/usr/local/git-2.9.5/bin
使/etc/profile文件生效:
# source /etc/profile
测试git是否安装成功
# git --version
若执行git命令时出现如下错误提示:
fatal: Unable to find remote helper for'https'
则可以用git替换其中的https
这是因为编译安装git前没有安装curl-devel