#!/usr/bin/env bash
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
sudo yum install gcc perl-ExtUtils-MakeMaker
sudo yum remove git
cd /usr/src
sudo wget https://www.kernel.org/pub/software/scm/git/git-2.4.4.tar.gz
sudo tar xzf git-2.4.4.tar.gz
cd git-2.4.4
sudo make prefix=/usr/local/git all
sudo make prefix=/usr/local/git install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
sudo ln -s /usr/local/git/bin/git /usr/bin/git
source /etc/bashrc
git --version
- 最好用/etc/profile 代替/etc/nashrc(/etc/profile是对所有 shell 生效的,而/etc/bashrc只对 bash 生效),如果你是用的是 zsh 而不是 bash,也可以把/etc/bashrc改成/etc/zshrc
- 最新版本的 git 可以在 GitHub 上的 git 仓库页面找到,替换 wget 的网址即可