Linux Centos6.8 安装Git

首先,卸载旧git,centos 6.8 默认git版本1.7.1

yum remove git -y

然后,按照下面的步骤按照新版2.11.0

(1)升级系统

$ yum update

(2)安装依赖包

$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

(3)下载Git源码并解压

$ wget https://www.kernel.org/pub/software/scm/git/git-2.11.0.tar.gz

$ tar -zxvf git-2.11.0.tar.gz

$ cd git-2.11.0

(4)编译安装

$ make prefix=/usr/local/git all

$ make prefix=/usr/local/git install

编译安装出错了,

libgit.a(utf8.o): Infunction`reencode_string_iconv‘:/root/git-2.9.0/utf8.c:463: undefined reference to `libiconv‘libgit.a(utf8.o): Infunction`reencode_string_len‘:/root/git-2.9.0/utf8.c:502: undefined reference to `libiconv_open‘/root/git-2.9.0/utf8.c:521: undefined reference to `libiconv_close‘/root/git-2.9.0/utf8.c:515: undefined reference to `libiconv_open‘collect2:ld返回1make: *** [git-credential-store] 错误1

这样做:

cd 

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

tar -zxvf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure --prefix=/usr/local/libiconv  && make && make install

make clean

$ make prefix=/usr/local/git all

$ make prefix=/usr/local/git install

(5)配置git环境变量

$ vim /etc/bashrc

在最后一行添加

export PATH=/usr/local/git/bin:$PATH

(6)验证是否安装成功

$ source /etc/bashrc

$ git --version(提示版本号说明安装成功)

(7)基本配置

$ git config --global user.name 'username'

$ git config --global user.email 'useremail'

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容