GitHub 訪問慢?手把手教你幾招解決它!
由于眾所周知的原因,在國內(nèi)的網(wǎng)絡(luò)環(huán)境下,訪問 Github 時(shí),網(wǎng)絡(luò)會阻斷或者很慢。本文提供了若干訪問方法。
1 使用 Github Mirror 下載
直接在 GitHub 倉庫前面拼接 Proxy 地址,不同的 Mirror 拼接方式可能有所不同。下面以拉取 https://github.com/shaowenchen/scripts 倉庫為例。
- $ git clone https://mirror.ghproxy.com/https://github.com/shaowenchen/scripts
- https://github.com.cnpmjs.org
- $ git clone https://github.com.cnpmjs.org/shaowenchen/scripts
2 通過 Gitee 導(dǎo)入 GitHub 項(xiàng)目
可以參考文檔: GitHub倉庫快速導(dǎo)入Gitee及同步更新, 將 GitHub 倉庫導(dǎo)入 Gitee。然后使用 Gitee 的地址拉取代碼。
文檔鏈接:https://gitee.com/help/articles/4284
3 配置 Github Host 地址
打開 https://www.ipaddress.com/ 查詢 github.com 的 IP 地址
編輯本地 /etc/hosts 文件,添加如下內(nèi)容:
- 140.82.112.4 github.com
或者直接使用開源項(xiàng)目 GitHub520 獲取最新的 IP 地址。
項(xiàng)目地址:https://github.com/521xueweihan/GitHub520
接著就可以拉取代碼了,但是速度并不會很快,因?yàn)?Github 用的是美國 IP。
4 配置命令行代理
如果有可用的代理服務(wù),那么在本地 Terminal 中配置代理即可。
- # Proxy
- function proxy_off(){
- unset http_proxy
- unset HTTP_PROXY
- unset https_proxy
- unset HTTPS_PROXY
- echo -e "已關(guān)閉代理"
- }
- function proxy_on(){
- export http_proxy="http://127.0.0.1:1087";
- export HTTP_PROXY="http://127.0.0.1:1087";
- export https_proxy="http://127.0.0.1:1087";
- export HTTPS_PROXY="http://127.0.0.1:1087";
- echo -e "已開啟代理"
- }
本文轉(zhuǎn)載自:「陳少文的網(wǎng)站」,原文:https://tinyurl.com/4tubycn9 ,版權(quán)歸原作者所有。歡迎投稿,投稿郵箱: editor@hi-linux.com。