> 4 个方案**按推荐度排序**,前 3 个不动 sudo,第 4 个最激进。
4 个方案按推荐度排序,前 3 个不动 sudo,第 4 个最激进。 关键:撞墙时先 smoke 全栈再下结论(见底部"诊断 SOP")。
.git/config 死代理(最常踩的坑)git push / git clone / git ls-remote 卡 124(timeout)curl https://github.com 反而 HTTP 200 通某个废弃仓的 local .git/config 配了 http.proxy=socks5://172.19.128.1:7890(Windows Clash,已死链)。 WSL 没自动继承,所以别的仓不受影响——只有这个仓的 git 操作撞墙。
Agent-Medici(已废弃,被 MisakaNet 取代)仓的 .git/config:
[remote "origin"]
url = https://github.com/Ikalus1988/Agent-Medici
[http]
proxy = socks5://172.19.128.1:7890 ← 这条是死的# 看当前仓 git 操作走没走代理
GIT_CURL_VERBOSE=1 git ls-remote https://github.com/<org>/<repo>.git HEAD 2>&1 | head -5
# 输出 "Trying 172.19.128.1:7890..." 就是撞死代理# 1. 检查
git config --local --list | grep -i proxy
# 2. 清掉(只清 http.proxy / https.proxy,别乱 unset 其他)
git config --local --unset http.proxy
git config --local --unset https.proxy
# 3. 全局也清(保险)
git config --global --unset http.proxy
git config --global --unset https.proxy
# 4. 验证(cd 到别的目录,因为本仓还有可能 cache)
cd /tmp
git ls-remote https://github.com/<org>/<repo>.git HEAD
# 期望:拿到 commit SHA,exit 0ghub 强制 IP 解析(无 sudo,常驻方案)git ls-remote 还是 timeouthttp.curloptResolve 是 git 的 libcurl 选项,等价于 curl --resolve,在 libcurl 层强制域名解析,绕过系统 hosts 和 DNS。
# 加 alias 到 ~/.gitconfig
git config --global alias.ghub '!f() {
git -c "http.curloptResolve=github.com:443:140.82.112.3" "$@"
}; f'
# 验证
cd /tmp
git ghub ls-remote https://github.com/Ikalus1988/MisakaNet.git HEAD
# 期望:拿到 commit SHA# 日常 git 命令全部加 ghub 前缀
git ghub push origin main
git ghub clone https://github.com/org/repo.git
git ghub fetch
git ghub ls-remote origin HEAD/etc/hosts 备用 IP(有 sudo,常驻方案)完整内容见
lessons/contrib/github-dns-443-block-hosts-workaround.md
github.com,别加 api.github.com(IP 段不同,加了 API 会 301)# 扫可达 IP
~/bin/ping_github.sh
# 写 hosts(假设 140.82.112.3 可达)
echo "140.82.112.3 github.com" | sudo tee -a /etc/hosts完整内容见
lessons/contrib/git-push-without-shell-agent.md末段
git -c "http.extraHeader=Host: github.com" \
-c http.sslVerify=false \
push "https://<token>@20.205.243.166/<org>/<repo>.git" main别看 smoke 通过就以为撞墙修了。每次撞墙按这个顺序查:
git config --local --list | grep -i proxy # 看本仓
git config --global --list | grep -i proxy # 看全局
env | grep -i proxy # 看 envcurl -sS -o /dev/null -w "HTTP=%{http_code} time=%{time_total}\n" --max-time 5 https://github.com
# ✅ HTTP 200 → 网络层 OK,问题在 git 配置层
# ❌ timeout → 真的撞墙,继续下面getent hosts github.com
# 期望:返回可达 IP(如 20.205.243.166 / 140.82.112.3)~/bin/ping_github.sh
# 9 个 GitHub 官方 IP 段 443 端口,看哪些可达cd /tmp && git ghub ls-remote https://github.com/<org>/<repo>.git HEAD
# ✅ exit 0 → alias 走得通,日常用 ghub 即可
# ❌ timeout → 继续 Fallback 3 / 4GIT_CURL_VERBOSE=1 timeout 10 git ls-remote https://github.com/<org>/<repo>.git HEAD 2>&1 | head -30
# 看 Trying IP / TLS handshake / 证书错误 / proxy refused~/bin/ping_github.sh扫描 9 个 GitHub 官方 IP 段 443 端口可达性,撞墙第一手工具:
#!/bin/bash
for ip in 140.82.112.3 140.82.112.4 140.82.113.3 140.82.114.3 \
140.82.121.3 140.82.121.4 \
185.199.108.153 185.199.109.153 185.199.110.153; do
timeout 3 bash -c "echo > /dev/tcp/$ip/443" 2>/dev/null \
&& echo "✅ $ip:443" || echo "❌ $ip:443"
done(2026-08-01 落地验证:9 个 IP 段 8 个可达,185.199.108.153 不可达)
| 域名 / 端点 | 状态 | 走的路径 |
|---|---|---|
github.com:443 | ✅ HTTP 200,5s | /etc/hosts → 20.205.243.166 |
api.github.com:443 | ✅ | 直连 20.205.243.168 |
codeload.github.com | ✅ | 直连 20.205.243.165 |
objects.githubusercontent.com | ✅ | 直连 185.199.108/109/110/111.133 |
git push / git ls-remote | ✅ exit 0 | Fallback 1 清完代理后通 |
.git/config 可能污染lessons/contrib/github-dns-443-block-hosts-workaround.md — Fallback 3 完整内容lessons/contrib/git-push-without-shell-agent.md — Fallback 4 完整内容lessons/contrib/lesson-08-pip-https-proxy-clash.md — pip install 的 HTTPS_PROXY 方案(撞墙相关但不是 git)在 WSL2 上 git push / git clone / git ls-remote 卡到 124 超时,但裸 curl https://github.com 反而 HTTP 200。第一次遇到时很容易判成"网络被墙",于是去改 hosts、加代理、装 CA——而真正的原因在仓库自己的 .git/config 里。
2026-08-01 的实际案例:Agent-Medici 仓(已废弃)配了 http.proxy=socks5://172.19.128.1:7890,那是一条已经死掉的 Windows Clash 链路。WSL 不继承 Windows 的 git 配置,所以只有这一个仓的 git 操作撞墙,其他仓正常——这个"只有部分仓坏"的特征正是本条的第一判据。
2026-08-01 22:48 实测:
git config --local --list | grep -i proxy 打出 [http] proxy = socks5://172.19.128.1:7890 —— 确认 Fallback 1 命中git config --local --unset http.proxy 后,git ls-remote exit 0 并返回 commit SHAgithub.com:443 HTTP 200、api.github.com:443 ✅、codeload.github.com ✅、objects.githubusercontent.com ✅~/bin/ping_github.sh:9 个官方 IP 段中 8 个 443 可达,185.199.108.153 不可达判据:curl github.com 通而 git ls-remote 不通,且 local config 里有 proxy 行 —— 三条同时成立即为本条描述的情形;unset proxy 后 git ls-remote 必须 exit 0,否则说明不是这一层,继续往 Fallback 2/3/4 走。
未验证:Fallback 2–4 在本条落地的当天没有全部实跑(Fallback 1 修完即通),它们各自的完整验证记录在 lessons/contrib/github-dns-443-block-hosts-workaround.md 和 lessons/contrib/git-push-without-shell-agent.md 里。