为github添加代理(windows)

以下内容均在windows环境下使用

设置https代理

在git窗口复制粘贴下面命令(https://github.com/Fndroid/clash_for_windows_pkg)

clash默认端口是7890

git config --global https.proxy socks5://127.0.0.1:代理端口

取消https代理

git config --global --unset https.proxy

查看https代理

git config --global --get https.proxy

设置ssh代理

  • 找到自己的git配置文件
    C:\Users\用户名\.ssh\config
    复制粘贴下面内容到config文件
Host github.com
 Hostname ssh.github.com
 
 IdentityFile /c/users/xxx/.ssh/id_rsa
 User git
 Port 443
 ProxyCommand   "D:\Git\mingw64\bin\connect.exe" -S 127.0.0.1:代理端口 %h %p

修改内容:

  • 将 IdentityFile后面的 /c/users/用户名/.ssh/id_rsa改为自己id_rsa文件路径,格式不要变。
  • 将ProxyCommand 后面的 "D:\Git\mingw64\bin\connect.exe" 改为自己的connect.exe路径,一般在git的安装目录下的mingw64\bin文件夹内
  • 代理端口设为自己的

取消ssh代理

清空config文件的内容

测试clone速度

大小约为500MB
ssh:git clone git@github.com:singgel/JAVA.git

https:git clone https://github.com/singgel/JAVA.git

对比结果

加速前

$ git clone git@github.com:singgel/JAVA.git
Cloning into 'JAVA'...
remote: Enumerating objects: 217, done.
remote: Counting objects: 100% (106/106), done.
remote: Compressing objects: 100% (54/54), done.
Receiving objects:  10% (22/217), 332.00 KiB | 75.00 KiB/s

加速后

$ git clone git@github.com:singgel/JAVA.git
Cloning into 'JAVA'...
remote: Enumerating objects: 217, done.
remote: Counting objects: 100% (106/106), done.
remote: Compressing objects: 100% (54/54), done.
client_loop: send disconnect: Broken pipeiB | 2.94 MiB/s
posted @ 2023-07-13 13:32  xiuer211  阅读(1555)  评论(0编辑  收藏  举报