如何在CentOS 6.x/7.x上安装git及最新版

方式一、yum安装

# yum info git
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
Name        : git
Arch        : x86_64
Version     : 1.8.3.1 <--- 说明:当前系统是 CentOS7.x,在 6.x 上是 1.7.1
Release     : 12.el7_4
Size        : 4.4 M
Repo        : updates/7/x86_64
Summary     : Fast Version Control System
URL         : http://git-scm.com/
License     : GPLv2
Description : Git is a fast, scalable, distributed revision control system with an
            : unusually rich command set that provides both high-level operations
            : and full access to internals.
            : 
            : The git rpm installs the core tools with minimal dependencies.  To
            : install all git packages, including tools for integrating with other
            : SCMs, install the git-all meta-package.
# yum install -y git

方式二、源码包安装

步骤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. 下载&解压

源码文件(当前最新版本 **v2.16.1** @ **2018年2月9日**)

- 地址1:https://www.kernel.org/pub/software/scm/git/
- 地址2:https://github.com/git/git/release

# 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

步骤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

 

注意:如果安装完查看版本不是我们安装的最新版,请重新执行下面的操作

# yum remove -y git
# source /etc/bashrc
# git --version
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值