最近开始学习git,由于Oracle Enterprise Linux中git的自带版本比较低(1.7.1),以下是升级过程中遇到的一些问题并解决。
1.卸载旧版本的git
[root@DB Downloads]# git --version
git version 1.7.1
[root@DB Downloads]# yum remove git
2.安装git
尝试用yum来安装,但是发现下载的还是1.7.1
[root@DB Downloads]# yum install git
······
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
git x86_64 1.7.1-9.el6_9 public_ol6_latest 4.6 M
Installing for dependencies:
perl-Git noarch 1.7.1-9.el6_9 public_ol6_latest 28 k
Transaction Summary
================================================================================
······
最后决定用源码来安装
参考1:https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git
参考2:https://blog.csdn.net/jianjun_jiang/article/details/67061806
安装包依赖
[root@DB Downloads]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
[root@DB Downloads]# yum install asciidoc xmlto docbook2x
获取源码
[root@DB Downloads]# wget https://github.com/git/git/archive/v2.2.1.tar.gz
100%[======================================>] 5,145,893 32.9K/s in 4m 8s
2018-05-11 05:35:29 (20.2 KB/s) - “v2.2.1” saved [5145893/5145893]
[root@DB Downloads]# ls -l
-rw-r--r--. 1 root root 5145893 May 11 05:35 v2.2.1
保存的文件是:v2.2.1,直接解压会抛错,需要cp一份并加上后缀.tar.gz
[root@DB Downloads]# tar zxvf v2.2.1.tar.gz
tar (child): v2.2.1.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
[root@DB Downloads]# cp v2.2.1 v2.2.1.tar.gz
[root@DB Downloads]# chmod 755 v2.2.1.tar.gz
[root@DB Downloads]# tar zxvf v2.2.1.tar.gz
[root@DB Downloads]# ls -l
drwxrwxr-x. 19 root root 12288 Dec 18 2014 git-2.2.1
-rw-r--r--. 1 root root 5145893 May 11 05:35 v2.2.1
-rwxr-xr-x. 1 root root 5145893 May 11 05:45 v2.2.1.tar.g
进入加压文件完成剩下安装步骤
[root@DB Downloads]# cd git-2.2.1
[root@DB Downloads]# make configure
[root@DB Downloads]# ./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv
[root@DB Downloads]# make all doc
[root@DB Downloads]# make install install-doc install-html
[root@DB Downloads]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
[root@DB Downloads]# source /etc/bashrc
最后检测版本是否有更新
[root@DB Downloads]# git --version
git version 2.2.1