1

Recently, I noticed that when I've been git pulling my repo, it's been doing a git gc every single time. So I tried to run git gc manually, which gave me this error:

fatal: bad object 76cab35e0e21b7cf0bc8416661a67fbfb7f0e4ba
error: failed to run repack

I then tried to search .git/packed-refs and .git/objects/ and .git/index for this hash (and even tried just searching the filenames and contents of my entire .git/ directory for this hash), but it never appears. Neither does it appear in git fsck --full (which I guess probably refers to some files in .git/, so that makes sense).

How do I fix this? (I'm using git 2.3.2.)

jiangty
  • 311
  • 2
  • 9

1 Answers1

3

This happens because reflog has references to entries that have somehow vanished from the filesystem. Running git gc with --prune="0 days" will remove all references that are older than now that aren't tracked in the remote origin, and should fix the issue.

Karthik Rangarajan
  • 1,370
  • 8
  • 12