MacOS10.15安装Git(通过Homebrew安装)


MacOS10.15安装Git

一、所需网站

Git官网:https://git-scm.com

Homebrew官网:https://brew.sh

二、先安装Homebrew

1、第一种方法:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)

在terminal中输入该命令进行安装

报错:curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

在terminal中执行curl命令curl https://raw.githubusercontent.com/Homebrew/install/master/install.sh

依然是这个问题,尝试ping这个网址,ping raw.githubusercontent.com

猜测是DNS的问题导致,尝试修改hosts

查询网站的ip地址,使用https://www.ipaddress.com查询raw.githubusercontent.com的ip地址为199.232.68.133

修改MacOS的hosts文件sudo vi /etc/hosts,增加199.232.68.133 raw.githubusercontent.com

再次尝试ping的时候就可以ping通了

再次执行 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"安装即可。

2、第二种方法:

由于国内直接使用Homebrew官网的方式安装比较慢,很容易失败,所以可以用另一种方法。

1、先将官网的install.sh保存到本地文件

curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >>brew_install.sh 

2、执行该脚本,可能会卡在tapping homebrew/core

/bin/bash brew_install.sh

3、手动更换中科院的镜像来下载

git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

4、再次执行

/bin/bash brew_install.sh

5、安装成功

三、安装Git

实际上安装好Homebrew之后,git也已经安装好了

输入brew install git

安装完成


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM