git clone --depth と git fetch --unshallow

巨大なリポジトリを git clone しようとしたとき、以下のようなエラーで失敗することがある*1:

fatal: early EOF
fatal: The remote end hung up unexpectedly
fatal: index-pack failed

このようなときは次のように分割して git clone するとうまくいくかもしれない:

git clone --depth 1 <repo_URI>
cd <repo_dir>
git fetch --unshallow

上に出できた

git clone --depth N

は最新の N コミットだけを clone してくるやつで、

git fetch --unshallow

はそういう一部のコミット履歴しかないローカルリポジトリに対して完全な履歴を fetch してくれるみたいなやつ。