在 git 版本大于 2.35.1 时,会有个问题,操作外置磁盘等,会报错,需要每次添加仓库到配置文件
依赖
apt install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc xmlto
下载源码
wget https://www.kernel.org/pub/software/scm/git/git-2.35.1.tar.gz
解压
tar xf git-2.35.1.tar.gz
编译前配置,配置自己的安装路径
./configure prefix=~/.app/git-2.35.1/
编译并安装
make && make install
验证
~/.app/git-2.35.1/bin/git --version
设置环境变量,把安装软件包的bin目录配置到path
echo 'export PATH=~/.app/git-2.35.1/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
路上的坑
libcurl4-gnutls-dev : Depends: libcurl3-gnutls (= 7.58.0-2ubuntu3.16) but 7.68.0-1ubuntu2.7 is to be installed
解决方案是删掉这个包,然后继续
apt purge libcurl3-gnutls
# 备份
cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 编辑
vim /etc/apt/sources.list
把 /etc/apt/sources.list
替换成以下内容
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse