git status shows fatal: bad object HEAD

try this; it worked for me (Warning: this destroys work that exists only in your local repo):

rm -rf .git

You can use mv instead of rm if you don't want to lose 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


Your repository is corrupt. That means data is lost that cannot be recovered by git itself. If you have another clone of this repository, you can recover the objects from there, or make a new clone.

fatal: bad object HEAD means the branch referenced from HEAD is pointing to a bad commit object, which can mean it's missing or corrupt.

From the output of git fsck, you can see there are a few tree, blob and commit objects missing.

Note that using git itself is not enough to keep data safe. You still need to back it up in cases of corruption.

Tags:

Git

Github