1.安装依赖

sudo apt install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev make

2.下载git源码

wget https://www.kernel.org/pub/software/scm/git/git-2.46.0.tar.gz -O git.tar.gz

3.解压缩源码

tar -zxf git.tar.gz
cd git-*

4.编译安装git

make prefix=/usr/local all
sudo make prefix=/usr/local install

5.验证安装

git --version