这篇文章上次修改于 1104 天前,可能其部分内容已经发生变化,如有疑问可询问作者。

有时候我们在内网中办公,不能直接连接外网,这时候就需要设置代理。

为 Git Bash 设置代理的方法有两种:

  1. 命令行方式

    • 非全局设置方式
      git config http.proxy http://127.0.0.1:8088
      git config https.proxy http://127.0.0.1:8088
    • 全局设置方式
      git config --global http.proxy http://127.0.0.1:8088
      git config --global https.proxy http://127.0.0.1:8088

    如果想查看是否设置成功,可用如下命令:
    git config --get http.proxy
    git config --get https.proxy
    git config --get --global http.proxy
    git config --get --global https.proxy

  2. 文件配置方式
    path/to/install/Git/etc/bash.bashrc 文件添加:
    export http_proxy="http://127.0.0.1:1080"
    export https_proxy="http://127.0.0.1:1080"