6

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
  • 805
  • 9
  • 23
Jithin Raj P R
  • 6,427
  • 8
  • 36
  • 67

2 Answers2

23

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,427
  • 8
  • 36
  • 67
  • The fear of losing changes is real. But this solution worked like a charm. Just for safety, first clone the project in a new repo. Then follow the above steps. Thank you very much!! – Waleed93 Mar 19 '22 at 20:14
9

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,427
  • 8
  • 36
  • 67
kumar
  • 401
  • 4
  • 7