最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

CentOS 7 部署最新版本的git

LINX ajiang-tuzi 2954浏览

安装 git-2.12.0

git的安装:
yum 源仓库里的 Git 版本更新不及时,最新版本的 Git 是 1.8.3.1,但是官方最新版本已经到了 2.1X。想要安装最新版本的的 Git,只能下载源码进行安装。
1. 查看 yum 源仓库的 Git 信息:

# yum info git
[root@localhost print]#  yum info git
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * city-fan.org: cityfan.mirror.digitalpacific.com.au
 * epel: mirrors.tongji.edu.cn
 * extras: mirrors.aliyun.com
 * remi-safe: mirrors.tuna.tsinghua.edu.cn
 * updates: centos.ustc.edu.cn
已安装的软件包
名称    :git
架构    :x86_64
版本    :1.8.3.1
发布    :6.el7_2.1
大小    :22 M
源    :installed
来自源:base
简介    : Fast Version Control System
网址    :http://git-scm.com/
协议    : GPLv2
描述    : 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.

可安装的软件包
名称    :git
架构    :x86_64
版本    :1.8.3.1
发布    :12.el7_4
大小    :4.4 M
源    :updates/7/x86_64
简介    : Fast Version Control System
网址    :http://git-scm.com/
协议    : GPLv2
描述    : 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.

Development tools 没装的要装上,不然GCC编译时会出错

# yum -y groupinstall Development tools

GCC 用于编译安装包

# yum install gcc perl-ExtUtils-MakeMaker

再卸载CentOS自带的老版本git

 yum -y remove git

下载git并安装

# cd /usr/src
# wget https://www.kernel.org/pub/software/scm/git/git-2.12.0.tar.gz
# tar xzf git-2.12.0.tar.gz
# cd git-2.12.0
# make prefix=/usr/local/git all

此时报错

/usr/src/git-2.12.0/utf8.c:463:对‘libiconv’未定义的引用
libgit.a(utf8.o):在函数‘reencode_string_len’中:
/usr/src/git-2.12.0/utf8.c:524:对‘libiconv_open’未定义的引用
/usr/src/git-2.12.0/utf8.c:535:对‘libiconv_close’未定义的引用
/usr/src/git-2.12.0/utf8.c:529:对‘libiconv_open’未定义的引用
collect2: 错误:ld 返回 1
make: *** [git-credential-store] 错误 1

解决方案:


# ./configure --without-iconv
# make CFLAGS=-liconv prefix=/usr/local/git all
# make CFLAGS=-liconv prefix=/usr/local/git install

最后将git加入环境变量

# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
# source /etc/bashrc

完成!查看一下git的版本

# git --version
>> git version 2.12.0

转载请注明:(●--●) Hello.My Weicot » CentOS 7 部署最新版本的git