How to delete a commit on a git remote?

泪湿孤枕 提交于 2019-12-13 13:34:14

问题


How can I delete a commit on a git remote hosted by github.com? I already found multiple answers on SO that show how to remove a commit from the commit history of a branch. I attempted these, however my commit is still clearly available because I can browser directly to it using its hash.

So for clarity, my question is not how to remove a commit from the commit history of all my branches on my remote. My question is how to remove the commit itself, so that there is no record of it on the git remote that I previously pushed my branch to.

Solutions I've tried include:

Remove last commit from remote git repository

Rolling back local and remote git repository by 1 commit

EDIT: Git: permanently remove few commits from remote branch is another solution that didn't work for me. The reason this particular solution did not work is because it stays to "git push --force your revised local branch to the remote.", which doesn't delete commits from the remote and instead only removes them from the commit history of the current branch.


回答1:


Quote from "GitHub support" [1]:

Github runs gc on a periodic basis. If you want have the files removed from the repo immediately, you'll have to delete and recreate the repo.



来源:https://stackoverflow.com/questions/38679261/how-to-delete-a-commit-on-a-git-remote

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!