【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 init
git 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
に記述しておらず、コミット履歴のサイズが肥大化していた。
参考