Skip to content

GIT Status Error & Solution

Muhammad Tariq edited this page Mar 18, 2021 · 15 revisions

Issue

muhammad@muhammad:~/$ git status
error: object file .git/objects/ab/22d9d3d8148e2170702ef275eb975e5d6d276c is empty
error: object file .git/objects/ab/22d9d3d8148e2170702ef275eb975e5d6d276c is empty
error: object file .git/objects/ab/22d9d3d8148e2170702ef275eb975e5d6d276c is empty
fatal: loose object ab22d9d3d8148e2170702ef275eb975e5d6d276c (stored in .git/objects/ab/22d9d3d8148e2170702ef275eb975e5d6d276c) is corrupt

Cause of issue

This issue can arise if files are damaged by an improper shutdown of a computer/VM for any reason. Other possible reasons can be operating system crashes, power failures, computers catching on fire.
If you have unstaged or staged files then those will be corrupted.

Solution

This can be solved by the following commands

  • find .git/objects/ -size 0 -exec rm -f {} ;
  • git fetch origin
  • git symbolic-ref HEAD refs/heads/
  • git status

Ref: https://stackoverflow.com/questions/4254389/git-corrupt-loose-object

Clone this wiki locally