Remove an unreferenced commit from git repository
问题 I have a git commit history like this: U / A---B---C---D---E master Nothing points to the commit U , but I know its hash. How can I completely remove this commit from my repository as if it never existed? I'm the only person using this repo. I tried using git rebase , but that can either delete parts of a branch or move commits, but doesn't seem to be able to delete a single commit. If I do git checkout <hash> and then git reset --hard HEAD~1 I don't see the the commit anymore. Is it actually