Gitlab库已损坏前端显示500错误解决方法:remote: fatal: loose object xxx is corrupt

今天团队小伙伴们在git push的时候报错:

remote: error: object file ./objects/ba/8dd150f67fe38c7e9d8cf44eee7c38b0afe34e is empty
remote: error: object file ./objects/ba/8dd150f67fe38c7e9d8cf44eee7c38b0afe34e is empty
remote: fatal: loose object ba8dd150f67fe38c7e9d8cf44eee7c38b0afe34e (stored in ./objects/ba/8dd150f67fe38c7e9d8cf44eee7c38b0afe34e) is corrupt

咋一看吓一跳,数据文件坏掉啦?!赶紧搜索了一下,以下是解决方案。

参考链接:

https://stackoverflow.com/questions/36546774/gitlab-repository-corrupted-showing-500-error-on-frontend

执行以下步骤后,库恢复正常。

1. $ cd gitlab/repositories/<namespace>/<reponame>.git 

2. $ git fsck
If any error like below
error: object file objects/11/fbf0dfb1a54283e84044b5e99230efbafd77d8 is empty
error: object file objects/11/fbf0dfb1a54283e84044b5e99230efbafd77d8 is empty
fatal: loose object 11fbf0dfb1a54283e84044b5e99230efbafd77d8 (stored in objects/11/fbf0dfb1a54283e84044b5e99230efbafd77d8) is corrupt

3.  $ find . -size 0 -delete  
This will delete all files which has 0 byte size and corrupt

4.  $ git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (4970/4970), done.
error: HEAD: not a commit
error: refs/heads/master: not a commit
dangling commit de516dd3d99d13147b6e2f946fe5b8c0660e4eed

5.   Try to push code from local without add and commit 
$ git push origin <branch>
If got below error
remote: error: Could not read 5329f756010fad47026f112dc7126bdaa2f9ad7f
remote: fatal: Failed to traverse parents of commit  8eecd866caa916a3b2e8550153f0bb5a54a28919
remote: aborting due to possible repository corruption on the remote side.
fatal: protocol error: bad pack header

6.  Go to cd gitlab/repositories/<namespace>/<reponame>.git
$ rm -fr ref/head/<branchname>
$ git fsck
notice: HEAD points to an unborn branch (master)
Checking object directories: 100% (256/256), done.
notice: No default references
dangling commit eb84ebc9010ea3d3d5646b4eab1bacd358178fbd

7.  Try to push code from local without add and commit 
$ git push origin <branch>

Done your code updated successfully !!!

 

 

 

 

Leave a Reply

Your email address will not be published.