yethu
0
Q:

how to fix corrupted git file

Steps to fix
git status
show the empty/corrupt object file

rm .git/objects/08/3834cb34d155e67a8930604d57d3d302d7ec12
remove it

git status
I got fatal: bad object HEAD message

rm .git/index
I remove the index for the reset

git reset
fatal: Could not parse object 'HEAD'.

git status
git pull
just to check whats happening

tail -n 2 .git/logs/refs/heads/MY-CURRENT-BRANCH
prints the last 2 lines tail -n 2 of log branch to show my last 2 commit hash

git update-ref HEAD 7221fa02cb627470db163826da4265609aba47b2
I pick the last commit hash

git status
shows all my file as deleted because i removed the .git/index file

git reset
continue to the reset

git status
verify my fix

Note: The steps starts when I landed on this question and used the answers as reference.

0

New to Communities?

Join the community