git 配置和加速
2019-07-24 本文已影响0人
CoderShmily
一、git 配置
1、在终端输入命令
此处我的服务器设置 socks5协议,端口号1080,具体的请根据自己的软件设置
// 对github进行配置
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global https.https://github.com.proxy socks5://127.0.0.1:1080
// 对谷歌的webp库地址进行配置
git config --global http.https://chromium.googlesource.com.proxy socks5://127.0.0.1:1080
git config --global https.https://chromium.googlesource.com.proxy socks5://127.0.0.1:1080
// 配置所有 git
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
2、同时,如果在输入这条命令之前,已经输入全局proxy的话,可以输入进行取消
// 移除对github配置
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy
// 移除对谷歌的webp库地址的配置
git config --global --unset http.https://chromium.googlesource.com.proxy
git config --global --unset https.https://chromium.googlesource.com.proxy
// 移除 全局 git 配置
git config --global --unset http.proxy
git config --global --unset https.proxy
// 查看git 全局配置
git config --global -l
二、 github 加速配置
分别运行下面指令,查看对用域名的ip地址
nslookup github.global.ssl.fastly.Net
nslookup github.com


将下列内容加入 /etc/hosts文件中
31.13.72.17 github.global.ssl.fastly.Net
52.74.223.119 github.com
刷新DNS缓存
sudo killall -HUP mDNSResponder
# 测试 git clone https://github.com/AFNetworking/AFNetworking.git
备用,上面不行了,换成下面的试试
151.101.185.194 github.global.ssl.fastly.net
192.30.253.112 github.com
151.101.184.133 assets-cdn.github.com
151.101.184.133 avatars0.githubusercontent.com
151.101.112.133 avatars1.githubusercontent.com