I changed all of the line endings in my project from dos mode to unix mode by removing all of the carriage returns from any file that had them:
grep -lIUr '^M' . | xargs sed -i 's/^M//'
I thought that it would ignore hidden dotfiles like .git/
, but it didn't, and now my git repository has been mangled.
git fsck
gives
Checking object directories: 100% (256/256), done.
error: inflate: data stream error (incorrect data check)
fatal: loose object 62f7323e2a025640a25214f13a670097876c1683 (stored in .git/objects/62/f7323e2a025640a25214f13a670097876c1683) is corrupt
There aren't any other copies of the repository checked out anywhere. Is there any way to recover from this? Is my repo dead?
Yes, it is. No luck, since all ^M are gone: maybe you can partially recover history and build another repo, but nothing more.
For the future, use greater care and proper tools like dos2unix
for converting line endings.