gitgithubgit-commitgit-pushgit-rewrite-history

How can I delete one commit completely from GitHub?


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.


Solution

  • My second comment has one typo which is recognized until now. Sorry for that. "follow that repo" should be "follow that link".


    This problem is solved now with the above comment help. IMHO, locally git show is enough to check whether the commit exists. Then after the push to GitHub when unnecessary commits deleted, we can contact GitHub Support using Virtual Agent. This can be invoked by inputting "remove commit" in "Subject" of the above link.

    If you care about one commit, then you choose the commit URL. Otherwise, as what I did, clear the "cached views" for the whole repository.