Git clone 克隆項目失敗
不小心刪了本地倉庫,重新git clone的過程中非常耗時,且常出現因連接問題導致clone失敗,真是惱人!
報錯如下:
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
有效解決方案
一、設置克隆深度
把克隆深度設置爲1,只包含最近的一次commit的一個分支,然後再fetch,可以解決因.git文件過大導致的clone失敗。
git clone [project address] --depth 1
cd [project path]
git fetch --unshallow
如果有需要,提供傳送門:如何解決Github提交次數過多導致.git文件過大
二、使用開源中國提供的代碼託管平臺Gitee
- 將待clone的github倉庫fork到自己的github
- 申請一個Gitee賬戶
- 在Gitee界面右上角有一個‘+’號,“從Github/GitLab導入倉庫”
- 在彈出的頁面中關聯Github賬戶
- 選擇“導入Github倉庫”,選擇對應的倉庫“導入”,非常快
- 按照 clone github倉庫的方法, clone Gitee賬戶中的倉庫;或者直接下載zip