I have a problem with git on Windows Azure. Git status shows - \"fatal: bad object HEAD\" and I tried running:
git fsck --full
git gc
But
I solved this by copying the branch data (with the errors) to my apple laptop local git folder.
Somehow in the terminal and when running: git status, tells me more specific data where the error occurs. If you look under the errors, hopefully you see a list of folders with error. In my case GIT showed the folder which was responsible for the error. Deleting that folder and commiting the branche, I succeeded. git status was working again the other devices updating by git pull; everything working again on every machine.
Hopefully this will work for you also.
I had a similar problem and what worked for me was to make a new clone from my original repository
Running
git remote set-head origin --auto
followed by
git gc
try this : worked for me
rm -rf .git
You can use mv
instead of rm
if you don't want to loose your stashed commits
then copy .git from other clone
cp <pathofotherrepository>/.git . -r
then do
git init
this should solve your problem , ALL THE BEST
In my case the error came out of nowhere, but didn't let me push to the remote branch.
git fetch origin
And that solved it.
I agree this may not solve the issue for everyone, but before trying a more complex approach give it a shot at this one, nothing to loose.
This happened to me on a old simple project without branches. I made a lot of changes and when I was done, I couldn't commit. Nothing above worked so I ended up with: