Tech/Answer Detail

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

Smith
Smith
Participant
346 Points
103 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?

Total Answered: 2
Total Marked As Answer: 0
Posted On: 01-Oct-2018 04:20

Share:   fb twitter linkedin
Answers
beginer
beginer
50 Points
20 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
Member
38 Points
14 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
banner

Blog

Active User (9)

 Log In to Chat