CentOS6.5升级git版本

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版本已经更新成功!

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值