git添加github代理

发布时间 2023-07-13 13:39:50作者: xiuer211

设置http代理

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

git config --global https.proxy http://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