Skip to content

Instantly share code, notes, and snippets.

@laispace
Last active March 18, 2024 07:06
Star You must be signed in to star a gist
Save laispace/666dd7b27e9116faece6 to your computer and use it in GitHub Desktop.
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@TLovers
Copy link

TLovers commented Nov 30, 2022

Mac ssh 设置还是很慢 5kb/s

@9xxxxxx
Copy link

9xxxxxx commented Mar 23, 2023

good!

@ChanaLii
Copy link

ChanaLii commented May 4, 2023

Nice!

@alongw
Copy link

alongw commented Jun 13, 2023

回答中的

git config --global https.proxy http://127.0.0.1:1080

中的https.proxy是否应该修改为http.proxy

@TLovers
Copy link

TLovers commented Jun 25, 2023

Mac 的ssh 有办法吗? 我试了上面的还是不行哇

@H-YWu
Copy link

H-YWu commented Jun 26, 2023

回答中的

git config --global https.proxy http://127.0.0.1:1080

中的https.proxy是否应该修改为http.proxy

这个是不是因为用的是HTTP代理而不是HTTPS代理(我这里Clash显示的是http+socks5混合端口),我也不太了解网络方面的问题,只是看到有人说这HTTP代理和HTTPS代理都可以同时代理两种。

@alongw
Copy link

alongw commented Jun 27, 2023

回答中的

git config --global https.proxy http://127.0.0.1:1080

中的https.proxy是否应该修改为http.proxy

这不是因为用的是HTTP代理而不是HTTPS代理(我这里Clash显示的是http+socks5混合端口),我也不太了解网络方面的问题,只是看到有人说这个HT TP代理和HTTPS代理都可以同时代理两种。

他的https代理使用了http协议,加上按照常理来说,这个地方应该就是http,只是问题的回答者复制粘贴忘记修改
我将他修改为http一切工作正常

Copy link

ghost commented Jul 3, 2023

可以用。。解决了我的问题,多谢

@killcoder0
Copy link

我亲测可以:

  1. clone: git clone -c http.proxy="127.0.0.1:xxxx" https://github.com/Gump8/xxxx.git
  2. fetch upstream: git -c http.proxy="127.0.0.1:xxxx" fetch upstream
    *注意: fetch 后面不能 -c,clone 是可以的

有效

@brothertao
Copy link

@omaidb
Copy link

omaidb commented Oct 10, 2023

@tengshe789
Copy link

thx a lot

@KELETU66666
Copy link

谢谢,非常感谢

@maxinzheng
Copy link

最新的git不能加单引号,比如v2rayNG可以这么配置 git config --global http.proxy socks5://127.0.0.1:10808

👍🏻

这个好使,牛逼

@cikiChe
Copy link

cikiChe commented Nov 27, 2023

最新的git不能加单引号,比如v2rayNG可以这么配置 git config --global http.proxy socks5://127.0.0.1:10808

如果要取消呢,我用我的网络在客户公司的电脑上拉代码,拉完我想去掉这个代理,咋办呢(抱歉,顺手一回,还没有搜索,等下搜索)

搜索到了:
git config --global --unset http.proxy
git config --global --unset https.proxy

@Randyx233
Copy link

Randyx233 commented Dec 16, 2023

Mac 的ssh 有办法吗? 我试了上面的还是不行哇

可以试试ssh使用443端口

To set this in your SSH configuration file, edit the file at ~/.ssh/config, and add this section:

Host github.com
    Hostname ssh.github.com
    Port 443
    User git

然后正常clone、pull都可以了

@Leo-AO-99
Copy link

Mac 的ssh 有办法吗? 我试了上面的还是不行哇

可以试试ssh使用443端口

To set this in your SSH configuration file, edit the file at ~/.ssh/config, and add this section:

Host github.com
    Hostname ssh.github.com
    Port 443
    User git

然后正常clone、pull都可以了

感谢,救了老命,mac+v2ray

@ysh83737
Copy link

Mac 的ssh 有办法吗? 我试了上面的还是不行哇

可以试试ssh使用443端口

To set this in your SSH configuration file, edit the file at ~/.ssh/config, and add this section:

Host github.com
    Hostname ssh.github.com
    Port 443
    User git

然后正常clone、pull都可以了

昨天突然开始抽风,操作不了GitHub,报错

kex_exchange_identification: Connection closed by remote host
Connection closed by 127.0.0.1 port 7890

一看端口,我还以为是代理的问题,折腾了半天无果。试了一下你的方案,就好了。感谢感谢!!

@james-curtis
Copy link

Mac 的ssh 有办法吗? 我试了上面的还是不行哇

可以试试ssh使用443端口
To set this in your SSH configuration file, edit the file at ~/.ssh/config, and add this section:

Host github.com
    Hostname ssh.github.com
    Port 443
    User git

然后正常clone、pull都可以了

昨天突然开始抽风,操作不了GitHub,报错

kex_exchange_identification: Connection closed by remote host
Connection closed by 127.0.0.1 port 7890

一看端口,我还以为是代理的问题,折腾了半天无果。试了一下你的方案,就好了。感谢感谢!!

clash tun mode 试试?

@oyal
Copy link

oyal commented Jan 17, 2024

Mac 的ssh 有办法吗? 我试了上面的还是不行哇

可以试试ssh使用443端口
To set this in your SSH configuration file, edit the file at ~/.ssh/config, and add this section:

Host github.com
    Hostname ssh.github.com
    Port 443
    User git

然后正常clone、pull都可以了

昨天突然开始抽风,操作不了GitHub,报错

kex_exchange_identification: Connection closed by remote host
Connection closed by 127.0.0.1 port 7890

一看端口,我还以为是代理的问题,折腾了半天无果。试了一下你的方案,就好了。感谢感谢!!

clash tun mode 试试?

我开启 Tun Mode 后报错:

ssh -T git@github.com
kex_exchange_identification: Connection closed by remote host
Connection closed by 198.18.0.7 port 22

换成 443 端口倒是可以,或者 Direct 直连,可以访问 22 端口

@huyinghuan
Copy link

Mac 的ssh 有办法吗? 我试了上面的还是不行哇

可以试试ssh使用443端口

To set this in your SSH configuration file, edit the file at ~/.ssh/config, and add this section:

Host github.com
    Hostname ssh.github.com
    Port 443
    User git

然后正常clone、pull都可以了

救了命了 老哥6666

@KevinFTD
Copy link

win10配置成功,如下,感谢各位的指导!

Host github.com
HostName github.com
User git
ProxyCommand connect -S 127.0.0.1:33211 %h %p

多谢,刚测试有效,速度起飞

@XTBoss
Copy link

XTBoss commented Jan 19, 2024

结合以上各位经验设置成功. 以下以macOS为准.

  1. https访问
    仅为github.com设置socks5代理(推荐这种方式, 公司内网就不用设代理了, 多此一举):
    git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
    其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.
    设置完成后, ~/.gitconfig文件中会增加以下条目:

    [http "https://github.com"]
        proxy = socks5://127.0.0.1:1086
    
  2. ssh访问
    需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:

    Host github.com
        User git
        ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
    

    如果是在Windows下, 则需要个性%home%.ssh\config, 其中内容类似于:

    Host github.com
        User git
        ProxyCommand connect -S 127.0.0.1:1086 %h %p
    

    这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在\mingw64\bin\下面.

worked.

亲测可以,我的代理是Clash,端口改成默认的7890.
记录下问题过程: Clash 一开始使用Git命令没问题,突然某天提示:

ssh: connect to host ssh.github.com port 22: Connection refused
fatal: Could not read from remote repository.

win10配置:.ssh/config 配置文件供参考:

Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 22
ProxyCommand connect -S 127.0.0.1:7890 %h %p

亲测可以,困扰一天了~感谢

确实有效!感谢

@hexWars
Copy link

hexWars commented Jan 19, 2024

结合以上各位经验设置成功. 以下以macOS为准.

  1. https访问
    仅为github.com设置socks5代理(推荐这种方式, 公司内网就不用设代理了, 多此一举):
    git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
    其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.
    设置完成后, ~/.gitconfig文件中会增加以下条目:

    [http "https://github.com"]
        proxy = socks5://127.0.0.1:1086
    
  2. ssh访问
    需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:

    Host github.com
        User git
        ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
    

    如果是在Windows下, 则需要个性%home%.ssh\config, 其中内容类似于:

    Host github.com
        User git
        ProxyCommand connect -S 127.0.0.1:1086 %h %p
    

    这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在\mingw64\bin\下面.

worked.

亲测可以,我的代理是Clash,端口改成默认的7890.
记录下问题过程: Clash 一开始使用Git命令没问题,突然某天提示:

ssh: connect to host ssh.github.com port 22: Connection refused
fatal: Could not read from remote repository.

win10配置:.ssh/config 配置文件供参考:

Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 22
ProxyCommand connect -S 127.0.0.1:7890 %h %p

亲测可以,困扰一天了~感谢

确实有效!感谢

感谢,之前设置的代理莫名失效,本来以为是git最新版本的问题

@duval1024
Copy link

结合以上各位经验设置成功. 以下以macOS为准.

  1. https访问
    仅为github.com设置socks5代理(推荐这种方式, 公司内网就不用设代理了, 多此一举):
    git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
    其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.
    设置完成后, ~/.gitconfig文件中会增加以下条目:

    [http "https://github.com"]
        proxy = socks5://127.0.0.1:1086
    
  2. ssh访问
    需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:

    Host github.com
        User git
        ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
    

    如果是在Windows下, 则需要个性%home%.ssh\config, 其中内容类似于:

    Host github.com
        User git
        ProxyCommand connect -S 127.0.0.1:1086 %h %p
    

    这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在\mingw64\bin\下面.

worked.

亲测可以,我的代理是Clash,端口改成默认的7890.
记录下问题过程: Clash 一开始使用Git命令没问题,突然某天提示:

ssh: connect to host ssh.github.com port 22: Connection refused
fatal: Could not read from remote repository.

win10配置:.ssh/config 配置文件供参考:

Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 22
ProxyCommand connect -S 127.0.0.1:7890 %h %p

亲测可以,困扰一天了~感谢

thanks, it works

@han2722
Copy link

han2722 commented Jan 24, 2024

win10系统,结合前面几位老哥的,在config文件中加入这几句:
Host github.com
User git
ProxyCommand connect -S 127.0.0.1:7891 %h %p

测试有效,我也用是的Clash,最开始打开System Proxy(系统全局代理)都没用。
我的git不知道什么版本的,config文件的路径是C:\Program Files\Git\etc\ssh\ssh_config,用记事本打开然后加上上面三句就可以了,注意改一下端口跟你clash中的端口一致,我的是7891

@EndlessCheng
Copy link

前面的方法对我都不行,我的解决方法是:

  1. 下载 GitHub Desktop
  2. 打开 C:\Users\<UserName>\.gitconfig
  3. [remote "origin"]proxy = http://127.0.0.1:代理端口

@pochenyun
Copy link

pochenyun commented Feb 17, 2024

有的代理好像不允许22端口,改443或者别的什么就行了:

Host github.com
    Hostname ssh.github.com
    User git
    Port 443
    IdentityFile ~/.ssh/xxx

@SeaAster
Copy link

SeaAster commented Mar 9, 2024

前面的方法对我都不行,我的解决方法是:

  1. 下载 GitHub 桌面版
  2. 开放C:\Users\<UserName>\.gitconfig
  3. [remote "origin"]proxy = http://127.0.0.1:代理端口

适合我, 感谢!

@liyiersan
Copy link

win10系统,结合前面几位老哥的,在config文件中加入这几句: Host github.com User git ProxyCommand connect -S 127.0.0.1:7891 %h %p

测试有效,我也用是的Clash,最开始打开System Proxy(系统全局代理)都没用。 我的git不知道什么版本的,config文件的路径是C:\Program Files\Git\etc\ssh\ssh_config,用记事本打开然后加上上面三句就可以了,注意改一下端口跟你clash中的端口一致,我的是7891

太感谢了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment