I have a repo that when I run git fsck --full, I got a long list of broken commit ids:
Checking object directories: 100% (256/256), done.
Checking objects: 100% (861/861), done.
error: Could not read 0f514378e088c610cbeb8b047c63d4209736d1f9
failed to parse commit 0f514378e088c610cbeb8b047c63d4209736d1f9 from object database for commit-graph
error: Could not read 1e77fe5a6c4bec9bc9bd7ac5c00f2bbe98249b44
failed to parse commit 1e77fe5a6c4bec9bc9bd7ac5c00f2bbe98249b44 from object database for commit-graph
error: Could not read 2a86db8a8c83ac0fdb5050efa63b518fbeaf8146
failed to parse commit 2a86db8a8c83ac0fdb5050efa63b518fbeaf8146 from object database for commit-graph
error: Could not read 2d898d27a8858cfba7db93f79ada3bdca181758d
failed to parse commit 2d898d27a8858cfba7db93f79ada3bdca181758d from object database for commit-graph
...
error: Could not read fc80facb8f8bf3a5972c51b2e9ae5e63552db2f0
failed to parse commit fc80facb8f8bf3a5972c51b2e9ae5e63552db2f0 from object database for commit-graph
Verifying commits in commit graph: 100% (28/28), done.
I just could not figure out how to delete them. I tried git gc, git prune, none of them works...
also I have a commit that can be shown as diff with git show <commit_id>, but when I run git branch --contains <commit_id> , no branch is found, so I believe that is a dangling commit, but again, I tried everything I found on google. None works.
The commands I tried.
git prune --expire now
git gc --prune=now
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch filename --prune-empty --tag-name-filter cat -- --all"
...
git branch --contains <hash>would not find it. Try adding-ato include commits reachable from remote-tracking branches.git branch -a --contains <hash>returns nothing too...