Git repo issue: failed to unpack tree object HEAD

I recently encountered a similar problem, but not for HEAD:

fatal: failed to unpack tree object 27897029c61a19819a55923c664da5796cc82d1d
error: Submodule 'submoduleXYZ' could not be updated.
error: Cannot update submodule: submoduleXYZ

Updating the submodule didn't help. I resorted to git reset --hard origin/theBranchName, then git checkout theBranchName, and git pull.