What are dangling objects, and how do git fsck and the reflog relate to them?

Last updated 6 July 2026

  • Dangling objects exist in the object database but are unreachable from any branch, tag, or HEAD (e.g. after git reset --hard or deleting a branch).

  • git fsck verifies the database and reports them (e.g. dangling commit <sha>, or --lost-found).

  • The reflog records past positions of HEAD and branches, keeping such commits recoverable. Once entries expire (~90 days), git gc prunes them.

  • https://medium.com/etticblog/hunting-erased-secrets-in-dangling-commits-9d090210ee1e
  • https://dev.to/rijultp/stumbled-on-a-dangling-commit-heres-what-it-really-means-45gl
  • https://gist.github.com/ammarshah/a20c5cfc206f1aeb0f6e8db24eb5d17f
  • https://git-scm.com/docs/git-fsck
  • https://git-scm.com/docs/git-fsck/2.21.0
  • https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery
  • https://webcodingcenter.com/git/reflog-and-recovering-lost-work--finding-dangling-objects-with-fsck.html
  • https://git-scm.com/docs/user-manual/2.32.0
All Git interview questions