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