準備
從github 下載最新版的 官方的git 倉庫 https://github.com/git/git/releases 【順便膜拜一下大神,git的締造者是 linus Torvalds】
從倉庫中隨便選擇一個rc 的是待發布版本 可能有問題 我們直接下載 版本號只有數字的
下載 解壓
#下載
wget https://github.com/git/git/archive/v2.16.2.tar.gz
#解壓
tar xzvf v2.16.2.tar.gz
#進入到 git文件夾
cd git-2.16.2/
安裝 必要組件
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker
安裝步驟參考 https://github.com/git/git/blob/master/INSTALL
上面文檔中又有安裝組件的教程,如果沒有安裝,將會可能出現下面報錯
CC credential-store.o
In file included from credential-store.c:1:0:
cache.h:40:18: fatal error: zlib.h: No such file or directory
#include <zlib.h>
^
compilation terminated.
make: *** [credential-store.o] Error 1
進行安裝
$ make configure ;# as yourself
$ ./configure --prefix=/usr ;# as yourself
$ make all doc ;# as yourself
# make install install-doc install-html;# as root
檢查
[root@martincentos git-2.16.2]# git --version
git version 2.16.2
但是還有一個問題我的git 文檔沒有更新
只要敲一下 man git 在最下面就可以看到manpage的版本
更新git manpage
其實上面安裝git 的時候 也會提示gitmanpage 安裝有問題
我們單獨升級manpage
先從 https://mirrors.edge.kernel.org/pub/software/scm/git/ 下載manpage包
wget https://mirrors.edge.kernel.org/pub/software/scm/git//git-manpages-2.16.2.tar.gz
更新manpage
tar xzv -C /usr/local/share/man -f git-manpages-2.16.2.tar.gz
# 說明一下參數 -C 表示解壓到某個目錄中
root@martincentos ~]# tar --help | grep -e "-C"
-C, --directory=DIR change to directory DIR
-f 表示 tar 文件
現在重新檢查一下man git 到最下面
5. git@vger.kernel.org
mailto:git@vger.kernel.org
Git 2.16.2 02/15/2018 GIT(1)
(END)
升級完成 OH YEAH!
提示:操作之前最好備份一下/usr/local/share/man
文件夾