温馨提示:本文共843个字,读完预计3分钟。
yum install git
检查git版本
git –version
发现不是较新的版本或者是我们想要的版本
移除该版本git
yum remove git
下载编译工具
yum -y groupinstall Development Tools
下载依赖包
yum -y install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel
下载 Git 最新版本的源代码
wget https://www.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
登录https://github.com/git/git/releases查看git的最新版。不要下载带有-rc的,因为它代表了一个候选发布版本。
解压
tar -zxvf git-2.9.5.tar.gz
进入目录配置
cd git-2.9.5
./configure –prefix=/usr/local/git
安装
make && make install
配置全局路径
export PATH="/usr/local/git/bin:$PATH"
source /etc/profile
以上即为安装的全部步骤。
后续使用中,遇到错误
Unable to find remote helper for ‘https’
解决方法:
将 /usr/libexec/git-core 纳入 PATH,至少在使用 git 之前,设置一下PATH
PATH=$PATH:/usr/libexec/git-core
或直接在 /etc/profile 中修改。
配置环境变量的备用方案:
[root@bogon git-2.3.0]# echo
"export PATH=$PATH:/usr/local/git/bin"
> /etc/profile.d/git.sh
[root@bogon git-2.3.0]# source /etc/profile.d/git.sh
[root@bogon git-2.3.0]# git --version