Git push error: object file is empty/loose object is corrupt
Step 1: Make a backup of .git (in fact I do this in between every step that changes something, but with a new copy-to name, e.g. .git-old-1, .git-old-2, etc.):
cp -a .git .git-old
Step 2: Run
git fsck --full
you will get this error message
For example: error: object file .git/objects/0A/dsdadadadaaeer4r3434343434334f is empty
Step 3: Remove the above empty file this is in your .git/objects/
folder. Continue deleting the empty files.
Step 4: After deleting all of the empty files, now run
git fsck --full
Step 5: Try git reflog. Fail because HEAD is broken.
Step 6: Manually get the reflog:
git log origin/master..HEAD
Step 7: Note that from Step 6 we learned that the HEAD is currently pointing to the very last commit. So let's try to just look at the parent commit:
git show commit-id
Step 8: So now we need to point HEAD to commit-id
git update-ref HEAD commit-id
Hope this will work for you.
... failed to push some refs to '[email protected]:joemorano/app.git'
Could this have been caused by the computer shutting off before I could perform the first commit?
Definitely, yes.
Anyone encounter this error before?
Repair corrupted git repository
See also: How to fix corrupted git repository?
In this case, since you (presumably) have a non-corrupt backup on bitbucket, I'd start by cloning that to a fresh (good) clone, then see if I could recover any intermediate commits and files from the existing (bad) clone and/or its work-tree, putting them into the new (good) clone. Once you have recovered whatever is recoverable from the bad clone, you can abandon or delete it. (Depending on your computer and its file system checking and repair tools, you might want to run those as well, perhaps before doing anything else at all.)