状況
Could not push
% git push
error: inflate: data stream error (incorrect header check)
error: unable to unpack 946e__HASH__ header
fatal: loose object 946e__HASH__ in .git/objects/94/6e__HASH__) is corrupt
error: remote unpack failed: eof before pack header was fully read
error: failed to push some refs to 'git@server:ORG/REPO.git'
fsck …
% git fsck
error: inflate: data stream error (incorrect header check)
error: unable to unpack header of .git/objects/09/c6__HASH__
error: 09c6__HASH__: object corrupt or missing: .git/objects/09/c64__HASH__
and also cat-file
% git cat-file -t 09c6__HASH__
error: inflate: data stream error (unknown compression method)
error: unable to unpack 09c6__HASH__ header
fatal: loose object 09c6__HASH__ (stored in .git/objects/09/c6__HASH__) is corrupt
対応
- 元のローカルリポジトリ (
repo1
) をコピーしてバックアップしておく。
$ cp -R repo1 repo1.bkup - 新しく clone する (
repo2
)。
$ git clone remote.repo repo2 - 古い (壊れている) リポジトリ (
repo1
)の .git を削除する。
$ rm -fr repo1/.git - 新しいローカルリポジトリ (
repo2
) の .git を古いリポジトリ (repo1
) に移動する。
$ mv repo2/.git repo1/ - 古いリポジトリ (
repo1
) で commit の上、push をする。
$ cd repo1 $ git commit $ git push - 成功したら、新しいローカルリポジトリを削除する。
$ cd .. $ rm -fr repo2