V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
qviqvi
V2EX  ›  程序员

Git 配置代理无效

  •  
  •   qviqvi · 96 天前 · 1777 次点击
    这是一个创建于 96 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如果本地有 http 和 socks5 代理,命令行启动的。其他软件指定走代理,有效,但 git 配置代理仍然无效,命令行客户端也不打印日志,很奇怪

    但如果用火箭这种图形界面的客户端启动代理,git 就成功走代理了

    目前试过下面的配置均无效

    git config --global http.proxy 'http://127.0.0.1:1087'
    git config --global https.proxy 'http://127.0.0.1:1087'
    
    git config --global http.proxy socks5h://127.0.0.1:1080
    git config --global https.proxy socks5h://127.0.0.1:1080
    
    git config --global http.proxy socks5://127.0.0.1:1080
    git config --global https.proxy socks5://127.0.0.1:1080
    

    暂时通过改 hosts 或者图形界面客户端可以解决,但不明白为什么无效

    13 条回复    2024-01-24 09:08:32 +08:00
    skiy
        1
    skiy  
       96 天前
    直接 https_proxy=http://127.0.0.1:1087 git clone xxxx 这样就行了,没必要使用 git 就全部走全局啊。

    如果是 linux ,推荐使用 proxychains 这个工具,非常好用。
    Nosub
        2
    Nosub  
       96 天前 via iPhone
    浏览器可以打开 github 吗。
    mschultz
        3
    mschultz  
       96 天前   ❤️ 1
    你的 git 操作访问的是 HTTPS 协议站点还是走 SSH 协议?走 SSH 的话上面的代理设置确实会无效(全都是 http 设置)。

    另外站内早有这个问题的详细解决方案了,考虑了各种情况,描述很清楚,推荐阅读。https://www.v2ex.com/t/843383
    CEBBCAT
        4
    CEBBCAT  
       96 天前   ❤️ 1
    排查下 DNS 问题
    Nazz
        5
    Nazz  
       96 天前 via Android
    要配 ssh 代理而不是 https
    LL77
        6
    LL77  
       95 天前
    不是 git 配代理,是给终端配代理,export http_proxy=xxx && export https_proxy=xxx
    my3157
        8
    my3157  
       95 天前
    如果是 ssh 协议, .ssh/config 添加

    Host github.com
    HostName github.com
    Port 22
    User git
    ProxyCommand nc -X 5 -x socks5-host: socks5-port %h %p

    如果是 http 协议,设置 http proxy env
    clhlc
        9
    clhlc  
       95 天前
    编辑~/.ssh/config 加入

    Host github.com
    HostName github.com
    Port 22
    User git
    ProxyCommand nc -X 5 -x 127.0.0.1:7890 %h %p
    eaststarpen
        10
    eaststarpen  
       95 天前 via Android
    https://hellodk.cn/post/975

    推荐这个帖子,比较系统
    iphoneXr
        11
    iphoneXr  
       95 天前
    export ALL_PROXY=socks5://127.0.0.1:1080 #可以加速 git clone 下载速度
    sead
        12
    sead  
       95 天前
    ~/.gitconfig
    [http]
    proxy = http://127.0.0.1:1087
    [https]
    proxy = http://127.0.0.1:1087
    elboble
        13
    elboble  
       94 天前
    git 都是用 ssh 的了,所有 htttp ,https 的 proxy 都不管用了

    .ssh/config 里加配置可破

    https://stackoverflow.com/questions/19161960/connect-with-ssh-through-a-proxy#:~:text=ProxyCommand%20ncat%20%2D%2Dproxy
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2680 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 15:29 · PVG 23:29 · LAX 08:29 · JFK 11:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.