【Git】remote unpack failed:index-pack failedの対処法
困ったこと
remote: fatal: did not receive expected object xxxerror: remote unpack failed: index-pack failedTo https://github.com/xxx/xxx.git ! [remote rejected] main -> main (failed)error: failed to push some refs to 'https://github.com/xxx/xxx.git'GitHubで新規作成したリポジトリにローカルのプロジェクトを初回commit&pushしようとすると失敗した。
error: remote unpack failed: index-pack failedが原因のよう。
解決法
rm -rf .gitgit initgit add .git commit -m "first commit"git branch -M maingit remote add origin https://github.com/xxx/xxx.gitgit push -u origin main色々試行錯誤したが、結果的にローカルの.gitを削除しfirst commitをやり直すことで解決した。
そのプロジェクトは個人開発かつ初回のgit initから大して履歴が生まれていないため、この方法で問題ないと判断。
原因
調べたところアクセス権限周りの問題というものも見受けられたが、自分の場合はコミット履歴のファイル数やサイズが大きいことが原因のようだった。
というのもbuildして生成されるディレクトリ(いわゆるdist的なもの)を.gitignoreに記述しておらず、コミット履歴のサイズが肥大化していた。
参考