Overview:
I am unable to successfully pull changes in our repo to our production server.
Running "git fsck" on my repo returned 5 instances of the same error:
warning in tree [hash]: contains entries pointing to a null sha1
The error exists on all versions of our repo including the version hosted on bitbucket.
My colleague and I both have unpushed and uncommitted changes in our local versions of the repo that we'd very much like to preserve.
I've tried to google, stackoverflow, and man page my way out of this but I can't find a good guide that explains what's going on or how to fix the problem.
My colleague and I are relative noobs when it comes to GIT. We've got the basics down but we haven't spent any time in the low-level commands yet.
I'd appreciate any and all help to restore the integrity of my repo.
Detailed description:
My problems started when I tried to pull a remote branch to my production server. It should have been a simple update to the working directory but I got some vague error that I can't remember and found my working directory was corrupted.
Git status reported tons of untracked and modified files after the failed merge. I couldn't figure out how to fix the problem with git commands so I manually manipulated the file system to remove the files (but I didn't touch anything in the .git directory) and got my working directory back to a state where my production server would serve my website without errors.
Running "git fsck" on my repo returned 5 instances of the same error:
warning in tree [hash]: contains entries pointing to a null sha1
I ran git fsck on:
- my repo on my dev machine
- my colleague's dev machine
- a freshly cloned version repo from bitbucket on both dev and prod
Everything I tried shows the same warnings. So whatever the problem is, it's in all versions of our repo.
Calling "git ls-tree [tree hash reporting an error]" shows an normal directory printout along with the bad tree hash:
160000 commit 0000000000000000000000000000000000000000 [name of repo]
The closest thing to a solution I found is this stackoverflow post: How to remove an entry with null sha1 in a Git tree. However, I was unable to really comprehend the steps and cutting and pasting commands failed to resolve my problems.
My questions:
- What do these errors really mean? How serious are they?
- How do we repair our repo (if possible please go step-by-step for us noobs)?
- Should we be committing and pushing all our changes to the repo before we repair it or after?
- What are the implications of repairing the repo? How do we distribute the repair to all versions of the repo (eg. to dev machines, and the production server)?
- What causes this error and how do we prevent it from reoccurring?