为github添加代理(windows)

xiuer / 2023-07-13 / 原文

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

目录
  • 设置http代理
  • 取消http代理
  • 设置ssh代理
  • 取消ssh代理
  • 测试clone速度

设置http代理

在git窗口复制粘贴下面命令

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

取消http代理

git config --global --unset http.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/xxx/.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