Git clone 出現 "remote: fatal: object xxx is corrupted" 修復

git clone ssh://example.com/project.git # 出現下述錯誤

error: git upload-pack: git-pack-objects died with error.
remote: fatal: object 161824656702683f2b9c06a3511143f56da8ee0a is corrupted
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.

git clone -v ssh://example.com/project.git

Initialized empty Git repository in /home/user/project/.git/
[email protected]'s password:
Server supports multi_ack_detailed
Server supports side-band-64k
Server supports ofs-delta
want 1dd602b6095d36e8c50bcc1335f7b6b2320ab9cd (refs/heads/master)
done
remote: fatal: object f3c8013acb933dc392e3ac2905901671141fbae1 is corrupted
error: git upload-pack: git-pack-objects died with error.
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.

問題

發現 Server 上的 project.git 裡面的 objects 的 hash 檔案權限有問題(變 600), 所以無法讀取.

發生原因應該是用太多種方式 commit, push 吧~ (http, ssh push)

解法

  1. ssh git-server
  2. cd project.git/objects
  3. find . -type f -exec sudo chmod 644 {} \; # 把 object 裡面一律改成 644.

測試

git clone -v ssh://example.com/project.git

Initialized empty Git repository in /home/user/project/.git/
Server supports multi_ack_detailed
Server supports side-band-64k
Server supports ofs-delta
want 1dd602b6095d36e8c50bcc1335f7b6b2320ab9cd (refs/heads/master)
done
remote: Counting objects: 165, done.
remote: Compressing objects: 100% (151/151), done.
remote: Total 165 (delta 64), reused 0 (delta 0)
Receiving objects: 100% (165/165), 72.92 KiB, done.
Resolving deltas: 100% (64/64), done.

相關網頁

作者: Tsung

對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.

發表迴響

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料