Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove deleted commit that references an issue

Tags:

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?

like image 811
Nate Glenn Avatar asked Jul 13 '14 08:07

Nate Glenn


People also ask

How do I unlink an issue in GitHub?

Navigate to the issue you want to delete. On the right side bar, under "Notifications", click Delete issue. To confirm deletion, click Delete this issue.

What happens when you delete a commit?

It will reset you back to the most recent commit, and erase all the changes in your working tree and index. Lastly, if you need to find a commit that you "deleted", it is typically present in git reflog unless you have garbage collected your repository. HEAD~1 or just HEAD^ .

How do you get rid of an old commit?

First, remove the commit on your local repository. You can do this using git rebase -i . For example, if it's your last commit, you can do git rebase -i HEAD~2 and delete the second line within the editor window that pops up. Then, force push to GitHub by using git push origin +master .


1 Answers

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.

like image 136
Nevik Rehnel Avatar answered Oct 12 '22 04:10

Nevik Rehnel