方式一、yum安装
# yum install git
通过yum方式安装,版本比较旧,CentOS6.5上安装好是1.7.1版。如果想安装最新版或其他版本,需要使用源码编译安装的方式。
方式二、源码包安装
步骤1. 安装依赖包
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel # yum install gcc perl-ExtUtils-MakeMaker
步骤2. 卸载旧的git版本(如果之前有安装rpm包)
# yum remove git
步骤3. 下载&解压
# cd /usr/src # wget https://www.kernel.org/pub/software/scm/git/git-2.5.0.tar.gz # tar -zxvf git-2.5.0.tar.gz
或 # wget https://github.com/git/git/archive/v2.5.0.tar.gz 下载
步骤4. 编译安装
# cd git-2.5.0 # 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
步骤5. 检查git版本
# git --version git version 2.5.0
参考:http://stackoverflow.com/questions/21820715/how-to-install-latest-version-of-git-on-centos-6-x-7-x
时间: 2024-12-21 02:01:39