When I tried to clone a decently-huge git repository I got the error below. The most common issue is that the connection closes and the whole clone is cancelled.
Cloning into 'large-repository'...
remote: Counting objects: 20248, done.
remote: Compressing objects: 100% (10204/10204), done.
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
After a lot of trial and errors and a lot of “remote end hung up unexpectedly” I have a way that works for me.