Git error bad signature [How to Solve]

When submitting the file to the warehouse, the following error is thrown:

Report an error

Roc@DESKTOP-AF552U2 MINGW64 /e/note/Git (master)
$ git add
error: bad signature
fatal: index file corrupt

Cause Analysis

Because index file generally refers to the file .git/index in git. This file saves the information in the temporary storage area (index information). You can use git ls-files –stage to view the contents of the staging area. This file is very important! But now it reports index file corrupt, indicating that this file has been damaged. Fortunately, we have a way to regenerate this file: git read-tree or directly git reset.


  1. Enter the project directory: cd /path/to/dir
  2. Delete or rename the .git/index file: rm -f .git/index or mv .git/index{,.bak}
  3. Rebuild .git/index: git read-tree or directly git reset
Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
$ mv .git/index .git/index.bak

Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
$ git reset
Unstaged changes after reset:
M       Git/
M       Git/

Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   "Git/git\347\232\204\345\210\235\346\254\241\344\275\277\347\224\"
        modified:   "Git/git\347\232\204\351\200\211\351\241\271\345\217\202\346\225\"

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        Git/git failed to push some refs to
        "Git/git \346\212\245\351\224\231 index file"

no changes added to commit (use "git add" and/or "git commit -a")

Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *