在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
posted @ 2020-06-22 20:28  jiangcheng_15  阅读(182)  评论(0编辑  收藏  举报