22

I amended a commit a few times and did push --force each time (stupid mistake; I didn't realize until getting ready to send a PR that my editor had generated tons of noise by fixing tabs and trailing whitespace). The commits that I thought were no longer existent are still reachable on GitHub, and the issue reference causes a list of links to these non-existent commits to appear:

links to non-existent commits in GitHub issues

How do I get rid of these commits on the GitHub remote so that these extra links will go away?

Nate Glenn
  • 6,455
  • 8
  • 52
  • 95
  • 1
    possible duplicate of [How can I remove a commit on github?](http://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github) – Luke Peterson Jul 13 '14 at 08:50
  • maybe I need to wait for GitHub to run `git gc`? http://stackoverflow.com/a/9138899/474819 – Nate Glenn Jul 13 '14 at 09:52

1 Answers1

14

In general, you cannot remove a commit from Github yourself.

As pointed out in the answers to the other question linked as a possible duplicate, you can only reference new commits (which is what you've already done).

Running git gc in your clone will not help either, as this has nothing to do with the repo on Github.

Github run their own gc every now and then (the schedule and/or triggering events are not made public). GC'ing that commit might be prevented by that reference in the issue though, or the reference might persist (then 404'ing) even if the commit gets GC'd.

Usually, you would just ignore this kind of thing.

If it is a real problem though (e.g. sensitive data being accessible), you can contact Github Support and ask them to remove the reference and commit.

Nevik Rehnel
  • 49,633
  • 6
  • 60
  • 50
  • If this is an unpopular project or a fork you can also simply delete the project and recreate it. This is more in the case of sensitive data, than it is for noise removal, though. – Shou Jun 14 '18 at 17:59