在用git clone下载一些比较大的仓库时,经常会遇到由于仓库体积过大,网络也不稳定,导致下了半截就中断了,可以参考如下的下载方法。

  先用创建一个空目录,然后用git init初始化,然后用git remote add添加远程仓库,用git fetch --depth=1现在想要的分支,等下载完毕后再使用git fetch --unshallow下载全部的git历史。

以https://github.com/MiCode/Xiaomi_Kernel_OpenSource为例:

mkdir mi9_kernel
cd mi9_kernel git init git remote add origin https://github.com/MiCode/Xiaomi_Kernel_OpenSource.git git fetch origin cepheus-p-oss --depth= git fetch origin cepheus-p-oss --unshallow

完。

05-11 19:38