ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

提升github网站访问与clone速度

2021-03-20 22:01:26  阅读:132  来源: 互联网

标签:github -- clone global 访问 git https config


1.github访问

众所周知的原因,国内访问github是个老大难问题。经常访问不了,或者访问速度很慢,或者从github上面clone项目很慢,经常被搞得痛不欲生…

2.设置代理

为了方便访问github,可以采用配置代理的方式。
对于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

对于ssh协议,可以如下设置

//在~/.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

3.shell终端配置

想让终端走代理那么只需在 ~/.bashrc 或 ~/.zshrc 文件中,直接写入以下内容并保存:

alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1080"
alias unsetproxy="unset ALL_PROXY"
alias ip="curl -i http://ip.cn"

利用终端下载资源时,先执行 setproxy 命令,结束后执行 unsetproxy 命令如果终端提示 command not found: setproxy,说明配置没有生效,执行一下 source ~/.bashrc 或 source ~/.zshrc 即可。

标签:github,--,clone,global,访问,git,https,config
来源: https://blog.csdn.net/bitcarmanlee/article/details/115035433

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有