Ubuntu version is 16.04.5 LTS
1. Install the dependencies required for compilation
sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
Second, download the git source code package
Official address: https://github.com/git/git/releases
wget https://github.com/git/git/archive/v2.17.0.tar.gz --no-check-certificate
Three, source code compilation
tar xvf v2.17.0.tar.gz
cd git-2.17.0
make prefix=/usr/local/git all
make prefix=/usr/local/git install #安装git到/usr/local/git
Fourth, configure environment variables
vi /etc/profile, add the following three lines at the end
#GIT
export GIT_HOME=/usr/local/git
export PATH=$GIT_HOME/bin:$PATH
source /etc/profile