I have some orphaned commits accidentally committed to GitHub.
Following this QA answer, I use git reflog expire --expire-unreachable=now --all to remove them from git rev-list --all. (I tried use git gc --prune=now --aggressive, but maybe the repository is too big, it crashes and make all windows closed. I use Arch Linux and KDE Plasma 6. Maybe my 16 GB memory is a bit small.)
Then I tried git gc --prune=now. After that, git show foo_orphan_commit will show "fatal: ambiguous argument 'foo_orphan_commit': unknown revision or path not in the working tree.". It seems that the commit has been removed from the local repository.
But in GitHub, when the commit to delete has message "#1", then in the GitHub #1 issue it still shows the message like "Someone added a commit that referenced this issue ... foo_orphan_commit".
Then is there one way to remove that commit completely from GitHub? I expects the commit won't be showed in GitHub with the above message.
du -sh .git)? You might not need--aggressive. Also, do you care about local, or GitHub? Clearing the unreferenced commit from your local repo won’t affect GitHub – see docs.github.com/en/authentication/….