-
Star
1,163
You must be signed in to star a gist -
Fork
273
You must be signed in to fork 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 |
我的代理环境在另外一个电脑上,使用的是clash
本机与代理机器在同一网段上。
配置如下
- ~/.gitconfig 配置如下
#对所有请求代理 方案1
[http]
proxy = socks5://192.168.10.120:7890
#只对github.com 方案2
[http "https://github.com"]
proxy = socks5://192.168.10.120:7890
请问下,为什么我设置了域名匹配反而不能走代理了,有人知道为什么么?(方案1可以走代理,方案2不能走代理)
- ~/.ssh/conf 配置如下
Host github.com
ProxyCommand nc -v -x 192.168.10.120:7890 %h %p
这样配置不能走代理反而会生成一个以代理地址为名称的文件(文件名为:192.168.10.120:7890)
我想通过统一的代理机器代理我应该怎么做,谢谢
Thx.. :)
git config --global http.proxy 'socks5://127.0.0.1:1086'
Or:
- input:
git config --global -e
- input:
[http]
proxy = socks5://127.0.0.1:1086
[https]
proxy = socks5://127.0.0.1:1086
github
git config --global https.proxy socks5://127.0.0.1:1086
mac上有用,谢谢
能否在git clone的时候临时设置代理呢 比如: git clone ssh:xxxxx.git --proxy url:port ?不胜感激
It helps, thanks a lot.
# 只对 github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
@zhangle1 使用 git@xxoo.com 这种方式,是用的 SSH 协议。需要在 ~/.ssh/config 目录下配置
Host xxoo.com(改成你的站点) ProxyCommand connect -H 127.0.0.1:1080 %h %p
It works for me! thx!
Windows + ssh
可以了解一下 proxychains4 ,可以增长寿命。
仓库代码,通过SSH的方式,确实得设置ssh代理,没想到一个小小的代理都有这么多门道。。。。还得感叹富强不易
谢谢!!!
最新的git不能加单引号,比如v2rayNG可以这么配置 git config --global http.proxy socks5://127.0.0.1:10808
目前在 Windows 10 上使用 Clash
git config --global http.proxy socks5://127.0.0.1:7890
git config --global https.proxy socks5://127.0.0.1:7890
如果只想对某个地址进行代理,比如对 github.com
代理,就这样:
git config --global http.https://github.com.proxy socks5://127.0.0.1:7890
参考了 @xpalive 的方式,SSH 还得看完全文
我亲测可以:
- clone: git clone -c http.proxy="127.0.0.1:xxxx" https://github.com/Gump8/xxxx.git
- fetch upstream: git -c http.proxy="127.0.0.1:xxxx" fetch upstream
*注意: fetch 后面不能 -c,clone 是可以的
https是没用的,无论复制的地址有没有SSL加密,改http.proxy就行了。顺便蹲一个办法,有没有办法只设置单次clone使用代理?
我亲测可以:
clone: git clone -c http.proxy="127.0.0.1:xxxx" https://github.com/Gump8/xxxx.git
fetch upstream: git -c http.proxy="127.0.0.1:xxxx" fetch upstream
*注意: fetch 后面不能 -c,clone 是可以的
- ~/.ssh/conf 配置如下
Host github.com ProxyCommand nc -v -x 192.168.10.120:7890 %h %p
这样配置不能走代理反而会生成一个以代理地址为名称的文件(文件名为:192.168.10.120:7890)
我想通过统一的代理机器代理我应该怎么做,谢谢
如果你是在Linux下配置,那么应该为
ProxyCommand nc --proxy-type socks5 --proxy 127.0.0.1:7891 %h %p
ncat和netcat有些参数上的区别,见https://unix.stackexchange.com/questions/368155/what-are-the-differences-between-ncat-nc-and-netcat
这是什么原理
结合以上各位经验设置成功. 以下以macOS为准.
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
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
win10配置成功,如下,感谢各位的指导!
Host github.com
HostName github.com
User git
ProxyCommand connect -S 127.0.0.1:33211 %h %p
带认证的http proxy咋配置呢
谢谢!
git config --global https.proxy 'https://127.0.0.1:1086'
↓↓
git config --global https.proxy https://[your_proxy_ip]:[your_proxy_port]
配置了.ssh/config,还是不行,我怀疑和我的机场有关系,之前用的都是可以的,现在换了两个了还是不行,无语了都,太难了。
分享一个windows下可行的ssh配置
Host github.com
User git
# http proxy
ProxyCommand ncat --proxy 127.0.0.1:10809 %h %p
最新的git不能加单引号,比如v2rayNG可以这么配置 git config --global http.proxy socks5://127.0.0.1:10808
👍🏻
一直在使用,最近不太稳定
结合以上各位经验设置成功. 以下以macOS为准.
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
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
亲测可以,困扰一天了~感谢
Mac ssh 设置还是很慢 5kb/s
good!
Nice!
Mac 的ssh 有办法吗? 我试了上面的还是不行哇
回答中的
git config --global https.proxy http://127.0.0.1:1080
中的
https.proxy
是否应该修改为http.proxy
?
这个是不是因为用的是HTTP代理而不是HTTPS代理(我这里Clash显示的是http+socks5混合端口),我也不太了解网络方面的问题,只是看到有人说这HTTP代理和HTTPS代理都可以同时代理两种。
回答中的
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一切工作正常
可以用。。解决了我的问题,多谢
我亲测可以:
- clone: git clone -c http.proxy="127.0.0.1:xxxx" https://github.com/Gump8/xxxx.git
- fetch upstream: git -c http.proxy="127.0.0.1:xxxx" fetch upstream
*注意: fetch 后面不能 -c,clone 是可以的
有效
https proxy
https_proxy=https://demoUser:yourpassword@your.server:port git clone https://github.com/demo/demo.git
可以参考.gitconfig配置
https://blog.csdn.net/omaidb/article/details/118104908
thx a lot
谢谢,非常感谢
最新的git不能加单引号,比如v2rayNG可以这么配置 git config --global http.proxy socks5://127.0.0.1:10808
👍🏻
这个好使,牛逼
最新的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
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 的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
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
一看端口,我还以为是代理的问题,折腾了半天无果。试了一下你的方案,就好了。感谢感谢!!
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 试试?
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 端口
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
win10配置成功,如下,感谢各位的指导!
Host github.com HostName github.com User git ProxyCommand connect -S 127.0.0.1:33211 %h %p
多谢,刚测试有效,速度起飞
结合以上各位经验设置成功. 以下以macOS为准.
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
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
亲测可以,困扰一天了~感谢
确实有效!感谢
结合以上各位经验设置成功. 以下以macOS为准.
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
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最新版本的问题
结合以上各位经验设置成功. 以下以macOS为准.
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
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
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
前面的方法对我都不行,我的解决方法是:
- 下载 GitHub Desktop
- 打开
C:\Users\<UserName>\.gitconfig
[remote "origin"]
的proxy = http://127.0.0.1:代理端口
有的代理好像不允许22端口,改443或者别的什么就行了:
Host github.com
Hostname ssh.github.com
User git
Port 443
IdentityFile ~/.ssh/xxx
前面的方法对我都不行,我的解决方法是:
- 下载 GitHub 桌面版
- 开放
C:\Users\<UserName>\.gitconfig
[remote "origin"]
的proxy = http://127.0.0.1:代理端口
适合我, 感谢!
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
太感谢了
感谢up主的这篇文章,我整理了一下思路大家也可以参考,我发现在Ubuntu系统下,git clone很快,但是MAC里面很慢 @TLovers
环境配置:
Mac:OS 14.1.1. git version 2.39.3
Ubuntu: OS 22.04 git version 2.34.1,Ubuntu系统安装在Mac的虚拟机里面
VPN: ClashX,1.118.0,安装在Mac电脑上,代理端口:7890,配置如下图所示
1)验证下载速度的命令(GIT_CURL_VERBOSE 用于查看git的调试打印信息):
GIT_CURL_VERBOSE=1 git clone --depth=1 --recursive --shallow-submodules git@github.com:ClickHouse/ClickHouse.git
2)在执行上面这个命令时,我发现Ubuntu下载代码很快,Mac很慢,对比了调试打印信息,发现了一些不同的地方:
Ubuntu会走代理来下载代码,如下图所示:
3)然后我尝试在Mac给Git配置代理,命令如下:
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy https://127.0.0.1:7890
4)然后再次git clone,发现Mac下还是没有走代理,速度还是很慢。
5)我尝试检查代理端口是否正常启动,发现一个特别的地方,我的MAC电脑代理 可能 用的是localhost,而不是127.0.0.1
6)我再尝试在Mac给Git配置代理,命令如下:
git config --global http.proxy http://localhost:7890
git config --global https.proxy https://localhost:7890
7)确认Mac上git的配置
git config --list
8)再次执行git clone,Mac现在会走代理,速度好像快起来了:
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
这个是配在hosts 中吗
great!!!