Git - git status shows 'bad signature 0x00000000, index file corrupt'

0 votes
added Mar 11, 2021 in Git by lcjr First Warrant Officer (11,930 points)
edited Mar 23, 2021 by lcjr

If the problem is with the index as the staging area for commits (i.e. .git/index), you can simply remove the index (make a backup copy if you want), and then restore index to version in the last commit: 

rm -f .git/index
git reset
git add .
git commit -m "git fix message here"


If that not work, can try this second method.

How? Go to <YOUR_PROJECT_FOLDER>\.git\refs\heads\ and delete the problematic branch from the directory.

Delete .git\refs\heads\<YOUR_BRANCH_NAME> 

Followed by reset and commit the files, as showed in the following commands

git reset
git add .
git commit -m "git fix message here"



The issue of " You are on a branch yet to be born " can be fixed with second method too. - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.