How to resolve “Error: bad index Fatal: index file corrupt” in Git

Smith
Smith
2890 Points
78 Posts

Today I tried to get status in the 'Git Bash' for git repository but I get this error with the cloned repository:

$ git status
error: bad index file sha1 signature
fatal: index file corrupt

Is there any way to fix this, other than getting a new copy of the repository?

Views: 16867
Total Answered: 2
Total Marked As Answer: 1
Posted On: 01-Oct-2018 04:20

Share:   fb twitter linkedin
Answers
beginer
beginer
1544 Points
52 Posts
         

You can simply remove the index  (i.e. .git/index) (make a backup copy if you want), and then restore index to version in the last:

If you are using Git Bash use following commands:

rm -f .git/index
git reset
Posted On: 02-Oct-2018 08:02
Rashmi
Rashmi
1068 Points
19 Posts
         

First remove the index (i.e. .git/index) (make a backup copy if you want), and then restore index to version in the last commit:

On OSX/Linux:

rm -f .git/index
git reset --keep

On Windows:

del .git\index
git reset --keep
Posted On: 05-Oct-2018 20:08
Thanks
 - Smith  27-May-2019 05:18
 Log In to Chat