更新时间:2022-09-14 09:03:41
CentOS 6自带的git版本是1.7,
安装编译环境
安装gcc
1
|
# yum install gcc gcc-c++ autoconf make automake wget -y |
安装依赖包
1
2
3
4
5
6
7
8
9
10
|
# yum install perl curl-devel expat-devel gettext-devel openssl-devel zlib-devel -y # yum install cpio texinfo sgml2xml openjade perl-ExtUtils-MakeMaker -y # yum install asciidoc xmlto docbook2X -y // 为了能够添加更多格式的文档(如 doc, html, info) # cd /usr/bin // 剩下步骤为避免执行make all doc info时报:/bin/sh: line 1: docbook2x-texi: command not found # ll db2x_docbook2texi -rwxr-xr-x 1 root root 3762 11月 12 2010 db2x_docbook2texi # ln -s db2x_docbook2texi docbook2x-texi # ll db2x_docbook2texi docbook2x-texi -rwxr-xr-x 1 root root 3762 11月 12 2010 db2x_docbook2texi lrwxrwxrwx 1 root root 17 1月 15 12:31 docbook2x-texi -> db2x_docbook2texi |
卸载自带的git
1
|
# yum remove git -t |
源码编译git
下载最新版
1
2
|
# cd /data/toots/ # wget https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz |
解压
1
2
|
# tar zxvf git-2.15.1.tar.xz # cd git-2.15.1 |
编译安装
1
2
3
4
|
# make configure # ./configure --prefix=/usr/local/git // 配置安装路径 # make all doc info // 编译 # make install install-doc install-html install-info // 安装 |
完成后,你可以使用 Git 来获取 Git 的升级: 可选
1
|
# git clone git://git.kernel.org/pub/scm/git/git.git |
修改环境变量
1
2
3
4
5
|
# echo -e "# git\nexport PATH=/usr/local/git/bin:\$PATH"> /etc/profile.d/git.sh # cat /etc/profile.d/git.sh \ # git // 文件内容
export PATH= /usr/local/git/bin :$PATH
# source /etc/profile |
查看是否安装成功
1
2
|
# git --version git version 2.15.1
|