Improve the speed of github website access and clone

1. github access

For well-known reasons, domestic access to github is an old and difficult problem. I can't access it often, or the access speed is very slow, or the clone project from github is very slow, and it is often made painful...

2. Set up proxy

In order to facilitate access to github, you can use the configuration proxy method.
For http or https protocol, you can set as follows

//设置全局代理
//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

For the ssh protocol, it can be set as follows

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

If you want the terminal to act as a proxy, you only need to write the following directly in the ~/.bashrc or ~/.zshrc file and save it:

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

When using the terminal to download resources, execute the setproxy command first, and then execute the unsetproxy command after the end. If the terminal prompts command not found: setproxy, the configuration does not take effect, just execute source ~/.bashrc or source ~/.zshrc.

Guess you like

Origin blog.csdn.net/bitcarmanlee/article/details/115035433