1。安装 brew(可百度 brew 官网,参考安装)
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
2. 安装 git
brew install git
3. 备份旧的 git
cd /usr/local/bin
mkdir backup-git
mv git* ./backup-git/
4. 找到新的 git 安装目录
cd /usr/local/Cellar/git/2.20.1
5. 回到根目录,配置环境变量
cd ~
vim .bash_profile
#输入
export GIT=/usr/local/Cellar/git/2.20.1
export PATH=$GIT/bin:$PATH
:wq
6. 刷新环境变量,使配置生效
source .bash_profile
参考资料:[1]: https://www.cnblogs.com/songt…