Yesterday, I pushed to my fork of ConnectBot on GitHub. I pushed once, realized that I hadn't made the change the way I wanted, redid the commit and pushed again.
Now, GitHub has both commits:
- https://github.com/nylen/connectbot/commit/1cd775d – the first, “bad” commit
- https://github.com/nylen/connectbot/commit/987671c – the one I want to keep
My master branch is only tracking the second commit, but the first commit is still available and is still in my activity feed. How can I remove it to make sure no one accidentally pulls that commit instead of the corrected version?
Delete the repo or contact GitHub
Deleting the repo and recreating it without the bad commit seems to work if you can afford losing all issues. The data also disappears from the commit API (although push events are still visible). See also: https://stackoverflow.com/a/32840254/895245
If you can't afford to lose issue data, GitHub support can manually delete dangling commits. For example, when I uploaded all GitHub commit emails to a repo they asked me to take it down, so I did, and they did a gc
. Pull requests that contain the data have to be deleted however: that repo data remained accessible up to one year after initial takedown due to this.
Their current help page says:
you can permanently remove all of your repository's cached views and pull requests on GitHub by contacting GitHub Support.
GitHub will periodically garbage collect any commits (and other objects) that can not be reached from a top-level reference (such as a tag or a branch or reflog). This means that over time (say in the next month), this object will disappear.
Pulling should generate a pack that contains only objects that are referenced so no one should get that commit as a result of a clone or a pull. For example,
$ git clone git://github.com/nylen/connectbot.git
Cloning into connectbot...
remote: Counting objects: 6261, done.
remote: Compressing objects: 100% (1900/1900), done.
remote: Total 6261 (delta 3739), reused 5980 (delta 3520)
Receiving objects: 100% (6261/6261), 3.04 MiB | 3.40 MiB/s, done.
Resolving deltas: 100% (3739/3739), done.
$ git cat-file -t 1cd775d
fatal: Not a valid object name 1cd775d
If you really need it to be removed immediately, you would probably have to contact GitHub Support.