常用开发工具的代理与镜像源配置

以下端口示例均以本地代理 10808 为准,请根据实际端口修改。

Git

设置代理

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

查看代理

git config --global --get http.proxy
git config --global --get https.proxy

删除代理

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

仅对 github.com 使用代理

# 设置
git config --global http.https://github.com.proxy socks5://127.0.0.1:10808
# 查看
git config --global --get http.https://github.com.proxy
# 删除
git config --global --unset http.https://github.com.proxy

npm

修改镜像源

# 查看当前源
npm config get registry

# 切换为阿里源
npm config set registry https://registry.npmmirror.com/

# 恢复官方源
npm config set registry https://registry.npmjs.org/

设置代理

# 设置
npm config set proxy socks5://127.0.0.1:10808
npm config set https-proxy socks5://127.0.0.1:10808

# 查看
npm config get proxy
npm config get https-proxy

# 删除
npm config delete proxy
npm config delete https-proxy

yarn

修改镜像源

# 查看当前源
yarn config get registry

# 切换为阿里源
yarn config set registry https://registry.npmmirror.com/

# 恢复官方源
yarn config set registry https://registry.yarnpkg.com/

设置代理

# 设置
yarn config set proxy socks5://127.0.0.1:10808
yarn config set https-proxy socks5://127.0.0.1:10808

# 查看
yarn config get proxy
yarn config get https-proxy

# 删除
yarn config delete proxy
yarn config delete https-proxy