Chendi WuMediaBlog
Back to blog

缓存与代理配置

Windows DNS 缓存清除、Git / 终端在不同代理工具下的代理配置参考。

2026-03-04
NotesTools

Windows DNS 缓存清除

在 CMD 命令行窗口中执行:

ipconfig /flushdns

Git 访问问题解决方案

问题描述

当遇到 fatal: unable to access 错误时,通常是由于网络连接问题导致。

配置 Git 代理

前提条件

确保代理工具(如 Shadowsocks 或 V2Ray)已正常运行。

Shadowsocks 代理配置

# 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:1086

V2Ray 代理配置

Tip

HTTP 代理方式(推荐):

git config --global http.proxy http://127.0.0.1:10808 && git config --global https.proxy http://127.0.0.1:10808

SOCKS5 代理方式:

git config --global http.proxy socks5://127.0.0.1:10808 && git config --global https.proxy socks5://127.0.0.1:10808

Clash Verge 代理配置

Tip

HTTP 代理方式(推荐):

git config --global http.proxy http://127.0.0.1:7897 && git config --global https.proxy http://127.0.0.1:7897

SOCKS5 代理方式:

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 代理:不支持公钥免密,每次操作需输入用户名和密码

取消代理配置

git config --global --unset http.proxy && git config --global --unset https.proxy

终端网络代理配置

设置代理

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"

取消代理

unset http_proxy
unset https_proxy

验证配置

配置完成后,可以通过以下命令验证:

git config --global --get http.proxy
git config --global --get https.proxy
Copyright (c) 2023-PRESENT | wudi