7

I was working on a branch and it was working fine. After some work, when I type git status this happens:

mac-mini:production_designs jithinraj$ git status
error: bad signature
fatal: index file corrupt

Now I can't commit or do anything on my branch. Any solution for this without losing my data that was not committed?

BroVic
  • 979
  • 9
  • 26
Jithin Raj P R
  • 6,667
  • 8
  • 38
  • 69

3 Answers3

26

I fixed my issue without loosing my data -

  1. Deleted the index file manually.
  2. After that, I used the command git reset --keep (you may need to delete index.lock file as well)
  3. Then used the command git status(it will take some time) magically all my changed files were there for me to commit.

Thank you for your time guys. Really appreciate it.

Jithin Raj P R
  • 6,667
  • 8
  • 38
  • 69
10

Try to reset your git. it may be because of any index or file got corrupted.

Once I also faced the same problem. Got fixed with below command:

rm -f .git/index


git reset .

I hope this resolve that issue.

Jithin Raj P R
  • 6,667
  • 8
  • 38
  • 69
kumar
  • 441
  • 4
  • 9
1

The other answers didn't work for me, so I pulled an XKCD. Hey, if it works, it works!


Step out of your repo folder

cd ..

Rename the original (broken folder)

mv folder folder_backup

Re-clone the repo

git clone <repo>

Move the (possibly changed) files back

cp -r folder_backup/* folder

Now you have a working repo again, because you recloned it, with your (possibly changed) files, that you copied back, so now you can commit/push those changes.

NostraDavid
  • 195
  • 8