I believe, my Git repository is not in good shape, wherein when I do a
git fsck
I get the following warnings at the top.
103b5dd53f7a96f8e3a02aea0d3d4d9bb19644ed: contains zero-padded file modes
bb4729593e76f66b46292ad6ae61bfe909558337: contains zero-padded file modes
4709aa73691ce7da36dd22ccfd157c4514395330: contains zero-padded file modes
I tried the following (suggested by a colleague) to find the offending commits, so that I could correct them. I tried the following methods.
git rev-list HEAD
.git ls-tree -rd
to find all the relevant object SHAs.git fsck
.The logic of the above seemed right to me, but it was not able to find the offending commit.
git rev-list --all --remotes | while read commit; do git ls-tree -rd $commit | grep -E "103b5dd53f7a96f8e3a02aea0d3d4d9bb19644ed|bb4729593e76f66b46292ad6ae61bfe909558337|4709aa73691ce7da36dd22ccfd157c4514395330" && echo -e "HIT @ $commit\n\n"; done
What are we missing here? How can we find either the offending commit or file is having the problem? At the end, I want to fix the repository.
Adding workaround from comments as answer:
Rebuilding the repo using git fast-export
and then git fast-import
resolves the problem but SHA values will change and tree references are not brought over.
Create a new empty repository:
mkdir /newrepo
cd /newrepo
git init
Go back to the old one with the fsck warnings:
cd /oldrepo
Pipe the data over using fast-export from old data to fast-import in the new repo
git fast-export --all | (cd /newrepo && git fast-import)
Just a supplement with @9000's answer:
Create an empty git repo in ../newrepo
, and
git fast-export --signed-tags=strip --all | (cd ../newrepo/ && git fast-import)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With