錯誤描述
今天在github上使用 git clone 某個項目代碼的時, git clone https://github.com/XXXX/xxx-blog.git 下載速度很慢,然后下載一段時間后,總是提示下面的錯誤信息:
remote: Enumerating objects: 33, done.
remote: Counting objects: 100% (33/33), done.
remote: Compressing objects: 100% (8/8), done.
error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
錯誤原因
由於Http協議錯誤,當 pull 或者 clone 的時候,或者是 github 某個CDN被偉大的牆屏蔽所致。
解決辦法1
協議錯誤
先執行下列命令
git config --global http.postBuffer 5242880000
再執行git pull
或者 git clone
命令
解決辦法2
牆屏蔽
-
訪問 http://github.global.ssl.fast...獲取cdn域名以及IP地址
-
訪問 http://github.com.ipaddress.c... 獲取cdn域名以及IP地址
-
或者直接訪問https://www.ipaddress.com/網址查詢下面所需的地址對應的IP
修改hosts文件
將上述獲取的IP地址添加到hosts文件中
Mac在/etc/hosts
中;
windows在C:\Windows\System32\drivers\etc\hosts
中;
# fix git clone github project failed
140.82.113.3 github.com
199.232.5.194 github.global.ssl.fastly.net
192.30.253.120 codeload.github.com
刷新DNS緩存
Mac刷新DNS緩存
sudo killall -HUP mDNSResponder
sudo dscacheutil -flushcache
Windows更新DNS緩存
cmd命令窗口執行:
ipconfig /flushdns
使增加的映射生效。