Search code examples
linuxeclipsegitgit-bare

Git Bare repository fail. Missing necessary objects. Can't commit/push


About one month about I've created bare git repository. And over last month I've been committing my source changes from eclipse to that repository over SSH.

The problem occurred today, when I tried to commit and push updates from eclipse. Here is whole error I've got:

Repository ssh://[email protected]:22/home/dany/git/SVP2/
missing necessary objects
error: object file ./objects/60/916b83370c1535a4be9924e71e9954c01e82e0 is empty
error: object file ./objects/60/916b83370c1535a4be9924e71e9954c01e82e0 is empty
fatal: loose object 60916b83370c1535a4be9924e71e9954c01e82e0 (stored in ./objects/60/916b83370c1535a4be9924e71e9954c01e82e0) is corrupt
error: object file ./objects/60/916b83370c1535a4be9924e71e9954c01e82e0 is empty
error: object file ./objects/60/916b83370c1535a4be9924e71e9954c01e82e0 is empty
fatal: loose object 60916b83370c1535a4be9924e71e9954c01e82e0 (stored in ./objects/60/916b83370c1535a4be9924e71e9954c01e82e0) is corrupt

I can assume what is wrong, but I dont know how to solve it.

I think it may be related to the error on linux server where that repository is:

 Read-only file system

I don't know why and when my system switched to read only mode.

I'have back ups:

  • source code in my local machine in eclipse project, wich is also local git repository
  • git bundle file of this git repository

Can they be use to restore repository to working one?

Please help. I am frightened. I am quite new to git. I don't have any team member to ask for this. Please help.

-------------- Edit ---------------------

Thanks to: @codeWizard

On Remote bare repository

[email protected]:~/git/SVP2$ git fsck --full
error: object file ./objects/06/b08928836077489d0ede51a0af42c7807b1943 is empty
error: object file ./objects/06/b08928836077489d0ede51a0af42c7807b1943 is empty
fatal: loose object 06b08928836077489d0ede51a0af42c7807b1943 (stored in ./objects/06/b08928836077489d0ede51a0af42c7807b1943) is corrupt
[email protected]:~/git/SVP2$ 

On Local working repository

dany@dany1l:~/git/SVP2$ git fsck --full
Checking object directories: 100% (256/256), done.
dany@dany1l:~/git/SVP2$ 

Solution

  • I had normal dir and file backup of git repository in zip archive, which I used to restore, fix error.

    1. ~/git rename to ~/git_old_corrupted
    2. unzip git folders and files structured backup into ~/git
    3. commit and push to remote repository (one which was earlier corrupted)

    This commit have pushed my all earlier commits at once.

    Now it is back to normal again.