こんにちは!ウェブサバイバー運営のYeah-Manです!今回はgithubを利用してgitでpullした時に『RPC failed; curl 18 transfer closed with outstanding read data remaining』というエラーを吐いて、pullできなかった時の解決方法です!
実際に発生したエラーは以下のようなもの。


$ git clone https://github.com/※※※※※※/hogehoge.git
Cloning into 'hogehoge'...
remote: Enumerating objects: 860, done.
remote: Counting objects: 100% (860/860), done.
remote: Compressing objects: 100% (589/589), 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

色々調べたところ以下が原因のようでした。

『RPC failed; curl 18 transfer closed with outstanding read data remaining』の原因

この辺りの記事を参照するとどうも原因はhttpプロトコル経由でのcurl実行時発生する模様(SSHの場合は発生しないようです)。
たしかに該当リポジトリをdownloadsしたところ40MB以上のバイナリ画像ファイル群があるようでした。

解決方法

すでに原因で紹介した記事でも書いてありますが、gitのglobal設定で『post buffer』という設定があるので、この数値を上げてやることで解決しました。


git config --global http.postBuffer 524288000

ただ会社の後輩エンジニアで同じような現象が発生。リポジトリクローン時にこの『post buffer』を試しただけでは解決できなかったようで、以下コマンドでバッファ値を調整、clone時のコマンドも以下で叩いてやることで解決していました。


git config --global http.postBuffer 2M
git clone https://github.com/※※※※/hogehoge.git --depth 1

もし同じようなエラーに遭遇したら上記も併せてお試しください!

以上現場からでした!