首页 > 其他分享 >【Git】git设置代理

【Git】git设置代理

时间:2023-03-16 18:00:25浏览次数:41  
标签:Git -- global 代理 git proxy https config

在大陆访问github等网络非常不稳定,中途各种错误断开造成克隆项目失败,可以尝试设置代理解决(前提是得有代理,这里起的作用只是让git操作走代理路径,但是如果代理路径本身就不存在那也没用)

设置代理

1.http || https协议

//设置全局代理
//http
// 这里注意设置成你自己的端口,每个人可能配置不一样
git config --global https.proxy http://127.0.0.1:1080
//https
git config --global https.proxy https://127.0.0.1:1080
//使用socks5代理的 例如ss,ssr 1080是windows下ss的默认代理端口,mac下不同,或者有自定义的,根据自己的改
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080

//只对github.com使用代理,其他仓库不走代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global https.https://github.com.proxy socks5://127.0.0.1:1080
//取消github代理
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy

//取消全局代理
git config --global --unset http.proxy
git config --global --unset https.proxy

2.SSH协议

//对于使用git@协议的,可以配置socks5代理
//在~/.ssh/config 文件后面添加几行,没有可以新建一个
//socks5
Host github.com
User git
ProxyCommand connect -S 127.0.0.1:1080 %h %p

//http || https
Host github.com
User git
ProxyCommand connect -H 127.0.0.1:1080 %h %p

参考原文:https://www.jianshu.com/p/739f139cf13c

标签:Git,--,global,代理,git,proxy,https,config
From: https://www.cnblogs.com/sherlock-V/p/17223672.html

相关文章