1.卸载自带的git
apt-get remove git
2.验证是否卸载
git --version
3.下载git并将git添加到环境变量中wget https://github.com/git/git/archive/v2.2.1.tar.gz
或者直接在浏览器器下载:https://mirrors.edge.kernel.org/pub/software/scm/git/
4.安装所需软件包
ubuntu:
apt-get install libcurl4-openssl-dev -y
Centos:
yum install gcc perl-ExtUtils-MakeMaker
5.解压
tar zxvf v2.x.x.tar.gz
6.解压后安装
cd git-2.9.5/
mkdir -p /usr/local/git
make prefix=/usr/local/git all
make prefix=/usr/local/git install
7. 配置环境变量
sudo vim /etc/profile
export PATH=$PATH:/usr/local/git/bin
source /etc/profile
8.在Jenkins中的配置git
路径为/usr/local/git/bin/git