GitBucketを使っていて、clone/pull/fetchするときにエラーが出るようになった。
サーバーのリポジトリでgit fsck
-> git gc
を実行するとエラーが出ずに実行できるようになった。
状況
- クライアント
$ git clone gitbucketのリポジトリURL Cloning into 'リポジトリ名'... fatal: git fetch-pack: expected ACK/NAK, got 'ERR want コミットのSHA1らしきもの not valid' fatal: The remote end hung up unexpectedly
切り分け
- GitBucketが動いているサーバーでGitBucketを経由せずにクローンしてみる。
mkdir tmp
cd tmp
git clone <gitbucket.home>/repositories/<group>/<repo_name>.git
- 成功する
git clone http://localhost:port/git/<group>/<repo_name>.git
- 失敗する→GitBucketでなんか失敗
サーバー
- gitbucketがエラー出力していた。
org.eclipse.jgit.errors.MissingObjectException: Missing unknown コミットのSHA1らしきもの
org.eclipse.jgit.transport.WantNotValidException: want コミットのSHA1らしきもの not valid
コミットやファイルが多いリポジトリだし、なんとなく
git gc
で解決するのかなぁと。見たもの(直接解決につながったわけではない)
- WantNotValidException (JGit - Parent 4.3.1.201605051710-r API)
- Bug 257422 – org.eclipse.jgit.errors.MissingObjectException: Missing unknown bf6696fce2cff7455c58914cb9aea102fe9d6b35
- Bug 436782 – MissingObjectException: “Missing unknown…” prevents push to upstream
- Eclipse Community Forums: EGit / JGit » Missing unknown when doing pull
このあたりで git fsck
を叩いてみようと気づく。
やったこと
cd <gitbucket.home>/repositories/<group>/<repo_name>.git
git fsck
たくさんの dangling commit/tree が出力されたgit gc
git fsck
たくさんの dangling commit/tree が出力されたままだった- gitbucket経由でcloneしたところ成功した。
GitBucketのUIでもSettings -> Danger Zoneから Garbage collectionボタンにて実行できるはずなので、全く同じ問題が再発した場合は解決できるかもしれない。