日常网络报错与故障排查篇2026最新更新· 独立问题解答页

❓ 如何为终端命令行(Terminal / CMD / Git / PowerShell)配置 Clash 代理?

#终端代理#Git加速#PowerShell#CMD配置
💡
核心要点概述

开发者必看:一键配置 Git clone、NPM、pip、Docker 及终端全局走 Clash 代理的标准命令。

✓

完整解答与实操指引

程序员在终端执行 git clone、npm install、pip install 或 docker pull 时,命令行默认不会走系统代理。

方案一:为 Git 单独配置 Clash 代理(最常用)

Clash 本地默认监听 HTTP 端口为 7890,在终端运行以下命令即可:
bash 点击选中复制
# 开启 Git 走本地 Clash 代理
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

# 需要关闭 Git 代理时执行:
git config --global --unset http.proxy
git config --global --unset https.proxy


方案二:PowerShell / Bash 临时全局代理

在当前终端窗口中临时注入环境变量(关闭终端后自动失效):
powershell 点击选中复制
# Windows PowerShell 执行:
$env:http_proxy="http://127.0.0.1:7890"
$env:https_proxy="http://127.0.0.1:7890"
bash 点击选中复制
# macOS / Linux Terminal 执行:
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890

方案三:一劳永逸开启 TUN 模式(强烈推荐)

只要在 Clash Verge Rev 中开启 TUN 模式,全电脑底层全部终端命令、IDE 插件无序任何手动配置,自动获得全局极速加速!

📌 猜您还想了解的相关问题

👑独家合作: 隐形人

复制成功

优惠码已成功复制到剪贴板