Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git status shows fatal: bad object HEAD

Tags:

git

github

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 git fsck shows:

broken link from  commit 739df633f185ce5d1ab7eb97d619b28e7d81185a               to    tree 2a6d4876d135c1fa7cbe1348c62570006e895fc5 broken link from  commit 9c7eae5ffed34dbfac977e515dee675626b59f93               to    tree 400132d215ab9aced883a9971e648b82624b2032 broken link from  commit 9c7eae5ffed34dbfac977e515dee675626b59f93               to  commit 4a49af0a0cb64a0a0415734b11772d6df18561fb broken link from  commit bc3072f30e71c616a8196089e19a67a2c9c0a5ad               to    tree 0aa813c183487d0a1b1f7ae81501ca7a1168283f broken link from  commit d3bb4f8545e91ec8ace15ad31a3147d92a1d4242               to    tree 4682108accd8e72fe68858232386dffe60f9f02d broken link from  commit 6b34795c4b54286301bcdc0ed254a04c132cb2ad               to    tree 5c57dd3222d11924dba841d3cae517bdc9220601 broken link from  commit d70172d855391b93bc1c5eeb9b4226df525dfc6e               to  commit 390c8cbd527c8e707c51e25142e54421f4dd3948 broken link from  commit cc05e8d2e3733693ebb67d697ae4b65e51fea79a               to  commit 32f081f8b901425fd1e8898478f0551970bee0f5 broken link from    tree 6a75ed6d0311d800078e77f43d427d128372d5bc               to    blob 4a064d610c0e7207967d59934c8bc5f491f26dae broken link from    tree 6a75ed6d0311d800078e77f43d427d128372d5bc               to    tree 5c06ec964dcbade49287d0f36efe1f7b60f446e3 broken link from    tree b4855fa6734b5652a93a9b799eafe47fad0d13a0               to    blob 3e1fb421613dc9066cbf9c95eddc61619a9f8eed broken link from    tree b4855fa6734b5652a93a9b799eafe47fad0d13a0               to    tree 556a50048d42346c283c94b78ea278ba1d57d251 broken link from    tree 289c03409370c4ca7c12266ce2822a2976bd032b               to    blob 3abf3c48ada45f63404dcf4d675ddfdadcfa83c6 broken link from    tree 289c03409370c4ca7c12266ce2822a2976bd032b               to    blob 3fa569892003b468ed1301426dd6d96d9644be3c broken link from    tree 289c03409370c4ca7c12266ce2822a2976bd032b               to    blob 0a9a54a51e84f3bc34122dbce1146d895fcbe22c broken link from    tree 289c03409370c4ca7c12266ce2822a2976bd032b               to    blob 3fa48873564361b4d95830803ae77f79eeafaf5b 

git branch shows - *master

like image 904
dotnetrocks Avatar asked Nov 28 '13 10:11

dotnetrocks


People also ask

What is Head error?

Error Message 1012 (Head Error) When there is an error with the product, the error message appears on the screen. Check the cause and countermeasure, and then take appropriate action. To clear the error: Power off the product, or change print head check conditions.


2 Answers

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

like image 71
ganesh Avatar answered Sep 23 '22 02:09

ganesh


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.

like image 44
Ikke Avatar answered Sep 23 '22 02:09

Ikke