跳转至

centos7安装git

安装依赖包

yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel gcc perl-ExtUtils-MakeMaker wget curl-devel libcurl-devel

下载指定版本git

wget https://www.kernel.org/pub/software/scm/git/git-2.36.1.tar.gz --no-check-certificate

解压并安装git

tar -zxvf git-2.36.1.tar.gz
cd git-2.36.1
./configure --prefix=/usr/local/git all
make && make install

配置环境变量

echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
source /etc/profile

验证

git --version

卸载git

rm -rf /usr/local/git

解决git clone的问题

  1. 安装dns缓存服务
yum install nscd -y
  1. ping
ping github.global-ssl.fastly.net
ping github.com

得到两个域名的IP地址后,加入/etc/hosts

echo "157.240.2.50 github.global-ssl.fastly.net" >> /etc/hosts
echo "20.205.243.166 github.com" >> /etc/hosts
  1. 刷新dns缓存
nscd -i hosts