0

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.

9
  • 1
    How big is the repo (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/…. Commented Apr 27, 2024 at 1:56
  • @Ry- Thanks. I tried that just a moment ago. It seems to work for the local repo but not for Github. I will follow that repo. Commented Apr 27, 2024 at 1:59
  • 2
    stackoverflow.com/a/32840254/7976758 "If you pushed to GitHub, force pushing is not enough, delete the repository or contact support" Commented Apr 27, 2024 at 9:50
  • 1
    Github has helped removing my deleted history commits after I opened request tickets. Their works are high efficient. Commented Apr 27, 2024 at 22:56
  • 1
    @An5Drama If the problem is solved, you can answer your own question to complete the QA cycle. Commented Apr 27, 2024 at 23:24

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.