Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git repo corrupted, unable to status with: "BUG: fsmonitor.c:21: fsmonitor_dirty has more entries than the index"

Tags:

git

corruption

First indication of issue:

❯ git rebase -r master
BUG: fsmonitor.c:21: fsmonitor_dirty has more entries than the index (179457 > 1040)
zsh: abort      git rebase -r master

Got "stuck" in this state, not sure how to recover or repro:

❯ git status
BUG: fsmonitor.c:21: fsmonitor_dirty has more entries than the index (179457 > 1040)
error: git died of signal 6

❯ git log  # works

❯ git diff head~
error: git died of signal 6
BUG: fsmonitor.c:21: fsmonitor_dirty has more entries than the index (179457 > 1040)

❯ git diff head~..head~~  # works

❯ git checkout head
BUG: fsmonitor.c:21: fsmonitor_dirty has more entries than the index (179457 > 1040)
zsh: abort      git checkout head
like image 326
Kache Avatar asked Nov 28 '25 18:11

Kache


1 Answers

Turns out git's index got corrupted during the rebase.

From: https://git.seveas.net/repairing-and-recovering-broken-git-repositories.html

mkdir .git/my_backup
mv .git/sharedindex.* .git/my_backup
mv .git/index .git/my_backup
git reset --mixed  # rebuild index

updates:

likely related git mailing list threads:

  • https://public-inbox.org/git/[email protected]/T/#m3a0ae8d18c63d8372a3f3e846f0c358857e660b5
  • https://public-inbox.org/git/[email protected]/T/#m13a5ad383f040bb3a6be7641bd04aa20424a274c

Suspected culprit is setting config core.splitIndex along with core.fsmonitor (and/or possibly feature.manyFiles).

Though it may have been fixed in 2.4.1: https://github.com/git/git/commit/3704fed5eae8ca2fa20bcf6adb277ee83b012ce0

like image 119
Kache Avatar answered Nov 30 '25 13:11

Kache



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!