如何在CentOS 6.x/7.x上安装git及最新版以及git
源码包安装
步骤1. 安装依赖包
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc perl-ExtUtils-MakeMaker
步骤2.卸载旧的git版本(如果之前有安装rpm包)
# yum remove git
步骤3.下载&解压
# cd /usr/src
# wget https://www.kernel.org/pub/software/scm/git/git-2.15.0.tar.gz
# tar -zxvf git-2.15.0.tar.gz
或# wget https://github.com/git/git/archive/v2.15.0.tar.gz下载
步骤4.编译安装
# cd git-2.15.0
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
# echo"export PATH=$PATH:/usr/local/git/bin">> /etc/bashrc
# source /etc/bashrc
步骤5.检查git版本
# git --version
gitversion2.15.0
步骤5.git命令补全
在/usr/src/git-2.15.0 目录下
# cp contrib/completion/git-completion.bash ~/.git-completion.bash
# vi ~/.bashrc
最后一行加入source ~/.git-completion.bash
关闭SSH终端,再重新登入,检测一下,Git输入的时候,按tab键,Git命令是不是能自动补全了