1.执行如下命令查看git版本:
git --version
结果如下:
git version 1.7.1
从git的官方网站上可以看到,目前git的最新版本已经到了2.11,我们机器上的git版本太低
2.配置163网络yum源
参考下面的文章进行配置即可:
CentOS配置163yum源
3.下载配置Git新版本yum源脚本
vim git_repo_install.sh
#!/bin/bash
el5_download_install(){
wget -O /tmp/release.rpm ${1}
yum -y localinstall /tmp/release.rpm
rm -f /tmp/release.rpm
}
centos_install_epel(){
# CentOS has epel release in the extras repo
yum -y install epel-release
import_epel_key
}
rhel_install_epel(){
case ${RELEASE} in
5*) el5_download_install https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm;;
6*) yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm;;
7*) yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm;;
esac
import_epel_key
}
import_epel_key(){
case ${RELEASE} in
5*) rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL;;
6*) rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6;;
7*) rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7;;
esac
}
centos_install_ius(){
case ${RELEASE} in
5*) el5_download_install https://centos5.iuscommunity.org/ius-release.rpm;;
6*) yum -y install https://centos6.iuscommunity.org/ius-release.rpm;;
7*) yum -y install https://centos7.iuscommunity.org/ius-release.rpm;;
esac
import_ius_key
}
rhel_install_ius(){
case ${RELEASE} in
5*) el5_download_install https://rhel5.iuscommunity.org/ius-release.rpm;;
6*) yum -y install https://rhel6.iuscommunity.org/ius-release.rpm;;
7*) yum -y install https://rhel7.iuscommunity.org/ius-release.rpm;;
esac
import_ius_key
}
import_ius_key(){
rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY
}
if [[ -e /etc/redhat-release ]]; then
RELEASE_RPM=$(rpm -qf /etc/redhat-release)
RELEASE=$(rpm -q --qf '%{VERSION}' ${RELEASE_RPM})
case ${RELEASE_RPM} in
centos*)
echo "detected CentOS ${RELEASE}"
centos_install_epel
centos_install_ius
;;
redhat*)
echo "detected RHEL ${RELEASE}"
rhel_install_epel
rhel_install_ius
;;
*)
echo "unknown EL clone"
exit 1
;;
esac
else
echo "not an EL distro"
exit 1
fi
4.卸载老版本Git:
su
yum remove git
5.执行脚本安装:
sh git_repo_install.sh
6.安装新版本Git:
yum install git2u-daemon
7.检查安装版本:
git --version
结果如下:
git version 2.10.2
git版本已经更新成功!