Windows 下,怎么设置 cmd、git bash 走代理。。 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
fcmio

Windows 下,怎么设置 cmd、git bash 走代理。。

  •  1
     
  •   fcmio Jun 29, 2021 15313 views
    This topic created in 1762 days ago, the information mentioned may be changed or developed.
    set http_proxy=http://127.0.0.1:1080 set https_proxy=https://127.0.0.1:1080 

    不生效。。会是什么原因。。

    Supplement 1    Jun 29, 2021

    带回家里了,家里有软路由,谢谢各位…

    25 replies    2025-01-03 17:00:27 +08:00
    MakeItGreat
        1
    MakeItGreat  
       Jun 29, 2021 via Android
    Power shell
    $env:http_proxy="http://127.0.0.1:8966"
    $env:https_proxy="http://127.0.0.1:8966"

    Git
    git config --global http.proxy 'socks5://127.0.0.1:8960'
    git config --global https.proxy 'socks5://127.0.0.1:8960'
    具体我也不太懂,需要大佬解释
    neteroster
        2
    neteroster  
       Jun 29, 2021
    不是所有程序都按环境变量来走代理的,比如 git 按你这个就不行。#1 已经说了 git 怎么设置代理。
    iscraft
        3
    iscraft  
       Jun 29, 2021
    proxifier
    OmO
        4
    OmO  
       Jun 29, 2021
    wsl2 我这样搞过,始终无法走代理。。。
    codehz
        5
    codehz  
       Jun 29, 2021
    用 tun/tap 吧,彻底解决问题.jpg
    devtk
        6
    devtk  
       Jun 29, 2021
    直接用软路由吧,省心
    PUBG98k
        7
    PUBG98k  
       Jun 29, 2021
    kkcap
    PUBG98k
        8
    PUBG98k  
       Jun 29, 2021
    AoEiuV020
        9
    AoEiuV020  
       Jun 29, 2021
    大小写都试试?
    以及这个配置不适用于 ssh 方式使用的 git,这种需要配置 socks 代理比如我是使用 nc 在~/.ssh/config 配置 ProxyCommand,
    AoEiuV020
        10
    AoEiuV020  
       Jun 29, 2021
    @AoEiuV020 #9 啊我这是 linux 的配置,git bash 应该一样,其他可能没法参考,
    JohnShen927
        11
    JohnShen927  
       Jun 29, 2021   1
    之前折腾过很多方法。
    最终发现的完美方案还是路由器刷 openwrt
    fuse
        12
    fuse  
       Jun 29, 2021 via iPhone
    @PUBG98k 有些 app 很复杂的,
    有子进程的,怎么搞,比如 github desktop 调用 git
    ysc3839
        13
    ysc3839  
       Jun 29, 2021 via Android
    https_proxy 指的是请求的目标是 https 协议使用的代理。如果你的代理不支持 https,这里又写了 https 的话,会导致所有 https 请求都发不出去。
    ysc3839
        14
    ysc3839  
       Jun 29, 2021 via Android   1
    @MakeItGreat git 是用 libcurl 发送 http 请求的,而 socks5 代理协议在 libcurl 中含义是使用本地 DNS 解析域名,再通过代理访问,这可能会导致一些问题。建议使用 socks5h 。
    Wanerlove
        15
    Wanerlove  
       Jun 29, 2021   1
    CMD
    ```
    set http_proxy=http://127.0.0.1:22335 & set https_proxy=http://127.0.0.1:22335
    ```
    Power Shell
    ```
    $Env:http_proxy="http://127.0.0.1:22335";$Env:https_proxy="http://127.0.0.1:22335"
    ```
    Git
    ```
    git config --global https.proxy http://127.0.0.1:22335
    git config --global https.proxy https://127.0.0.1:22335
    ```
    lostberryzz
        16
    lostberryzz  
       Jun 29, 2021
    ssh 协议的话要在.ssh/config 里设置代理,https 协议的话 export 下环境变量就 ok 了
    PUBG98k
        17
    PUBG98k  
       Jun 29, 2021
    @fuse 会自动检测子进程.顺便代理
    interim
        18
    interim  
       Jun 29, 2021
    @OmO wsl2 你需要拿到宿主机的 IP,我使用正常。
    或者你可以通过 clash 的 TUN 模式,所有的流量都会走代理,包括 WSL2 的,也就不用单独配置了。
    gooin
        19
    gooin  
       Jun 30, 2021
    # HTTP:
    只对 github 进行代理,对国内的仓库不影响,可以这样设置
    git config --global http.https://github.com.proxy http://127.0.0.1:1912
    git config --global https.https://github.com.proxy https://127.0.0.1:1912

    取消代理
    git config --global --unset http.https://github.com.proxy

    # SSH:
    mac 上对 ssh 方式的 gitclone 配置
    Host github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    User git
    ProxyCommand nc -v -x 127.0.0.1:7890 %h %p
    jswh
        20
    jswh  
       Jun 30, 2021
    我用 Netch
    KickAssTonight
        21
    KickAssTonight  
       Jun 30, 2021
    export http_proxy=http://127.0.0.1:1080
    export https_proxy=http://127.0.0.1:1080
    git config --global http.proxy 'http://127.0.0.1:1080'
    git config --global https.proxy 'http://127.0.0.1:1080'
    kerr92
        22
    kerr92  
       Jun 30, 2021   2
    正好整理过一份花式代理设置方式 https://keqingrong.cn/blog/2021-02-19-proxy-and-pac
    HankAviator
        23
    HankAviator  
       Jul 1, 2021 via Android
    @OmO wsl2 没问题啊,是不是调用的 git 不对?如果 wsl2 里面装的,要填 nat 的地址的。
    theatom
        24
    theatom  
       Jan 10, 2022
    @codehz +1
    lthero
        25
    lthero  
       Jan 3, 2025
    @kerr92 #22 好东西
    About     Help     Advertise     Blog     API     FAQ     Solana     5134 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 90ms UTC 01:13 PVG 09:13 LAX 18:13 JFK 21:13
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86