-
Star
(1,215)
You must be signed in to star a gist -
Fork
(280)
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 |
仿照上面的内容写了以下配置方案,操作系统是 win 10,代理用 SSR,端口 1080。
先设置了git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080
接着用
git config --global --get http.https://github.com.proxy
得到反馈
socks5h://127.0.0.1:1080
说明设置成功。
下面在用户文件夹的 .ssh 中建立 config 文件,内容为ProxyCommand connect -S 127.0.0.1:1080 -a none %h %p Host github.com User git Port 22 Hostname github.com IdentityFile "C:\Users\****\.ssh\id_rsa" TCPKeepAlive yes ServerAliveInterval 600 IPQoS=throughput ServerAliveCountMax 120 Host ssh.github.com User git Port 443 Hostname ssh.github.com IdentityFile "C:\Users\****\.ssh\id_rsa" TCPKeepAlive yes ServerAliveInterval 600 IPQoS=throughput ServerAliveCountMax 120
显示:
socks5h://127.0.0.1:1080
可还是特别慢, 开了全局ssr, 端口也是1080
https是没用的,无论复制的地址有没有SSL加密,改http.proxy就行了。顺便蹲一个办法,有没有办法只设置单次clone使用代理?
为什么设置成这样的代理就能加速啊,这是什么原理?
请问一下,我只设置了git config --global https而没设置git config --global http的时候,clone一个google的git仓库依然不行,后来加上了http的设置才可以,我也是ss代理代理都和你们一样,有人知道这是为什么吗?我的clone仓库url是https的啊,但还是需要把http和https代理都挂上才可以吗?
没有单独的https代理协议,https也是属于http的代理协议的一部分
在windows上,在Git Bash里设置
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
会报错的,提示:
/usr/bin/bash: line 0: exec: nc: not found
因为这个bash是不带netcat的,也就找到不到nc命令。
在win10上,有的msysgit版本集成了connect工具,所以在windows上,可以把ssh的config文件设置为:Host github.com ProxyCommand connect -S 127.0.0.1:1080 %h %p
就可以给ssh加socks代理了。
I have done with these in ~/.ssh/config
Host github.com
HostName github.com
User git
# socks5 need: pacman -S mingw-w64-x86_64-connect mingw-w64-i686-connect
ProxyCommand connect -S 127.0.0.1:2801 %h %p
Thanks you all..
$ git clone git@github.com:testerSunShine/12306.git
Cloning into '12306'...
remote: Enumerating objects: 2730, done.
fatal: index-pack failed(468/2730), 8.00 MiB | 3.82 MiB/s
client_loop: send disconnect: Broken pipe
fetch-pack: unexpected disconnect while reading sideband packet
Thanks, it helps.
is slower 😫
nice job . worked!
结合以上各位经验设置成功. 以下以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.
对于使用git@协议的,可以配置socks5代理
在~/.ssh/config 文件后面添加几行,没有可以新建一个Host github.com ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p
Works for me! Thanks
thanks my git works.
my proxy tool is clash.
git config --global http.proxy 'socks5://127.0.0.1:your local proxy port
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'works for me, Thank you!
God now i can't solve it...
Good job!
quotes are required.
我的代理环境在另外一个电脑上,使用的是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 是可以的
work