缓存与代理配置
Windows DNS 缓存清除
在 CMD 命令行窗口中执行以下命令:
bash
ipconfig/flushdns
Git 访问问题解决方案
问题描述
当遇到 fatal: unable to access 错误时,通常是由于网络连接问题导致。


配置 Git 代理
前提条件
确保代理工具(如 Shadowsocks 或 V2Ray)已正常运行
Shadowsocks 代理配置
bash
# Windows
git config --global http.proxy http://127.0.0.1:1080 && git config --global https.proxy http://127.0.0.1:1080
# macOS
$ git config --global http.proxy http://127.0.0.1:1086 && git config --global https.proxy http://127.0.0.1:1086V2Ray 代理配置
TIP
HTTP 代理方式(推荐):
bash
git config --global http.proxy http://127.0.0.1:10808 && git config --global https.proxy http://127.0.0.1:10808SOCKS5 代理方式:
bash
git config --global http.proxy socks5://127.0.0.1:10808 && git config --global https.proxy socks5://127.0.0.1:10808Clash Verge 代理配置
TIP
HTTP 代理方式(推荐):
bash
git config --global http.proxy http://127.0.0.1:7897 && git config --global https.proxy http://127.0.0.1:7897SOCKS5 代理方式:
bash
git config --global http.proxy socks5://127.0.0.1:7897 && git config --global https.proxy socks5://127.0.0.1:7897代理协议差异
- HTTP 代理: 支持通过 SSH 公钥免密登录 GitHub
- SOCKS5 代理: 不支持公钥免密,每次操作需输入用户名和密码
取消代理配置
bash
git config --global --unset http.proxy && git config --global --unset https.proxy终端网络代理配置
设置代理
bash
export http_proxy=http://127.0.0.1:1087
export https_proxy=http://127.0.0.1:1087
export no_proxy="127.0.0.1,localhost,*.inter.com"取消代理
bash
unset http_proxy
unset https_proxy验证配置
配置完成后,可以通过以下命令验证:
bash
git config --global --get http.proxy
git config --global --get https.proxy