Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any solution for git - error: bad signature without losing (non-committed) data

Tags:

git

github

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?

like image 691
Jithin Raj P R Avatar asked Oct 11 '17 12:10

Jithin Raj P R


People also ask

How do I fix a corrupted index file?

To rebuild the index of a corrupt indexed file, make sure that the corrupt indexed file is not still open in the Data File Editor. Then, click Data Tools>Fix File Index on the Tools menu.

How do I fix a corrupted index in git?

To rebuild the index, you can simply do git reset --mixed . This makes the index look like the last commit while leaving the worktree alone. If you had any local changes you git add ed but did not commit yet, you will need to re-add those.

What is a git index file?

The Git index is a critical data structure in Git. It serves as the “staging area” between the files you have on your filesystem and your commit history. When you run git add , the files from your working directory are hashed and stored as objects in the index, leading them to be “staged changes”.


1 Answers

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.

like image 179
Jithin Raj P R Avatar answered Sep 18 '22 00:09

Jithin Raj P R