如何删除git远程提交? [英] How to delete a commit on a git remote?

查看:169
本文介绍了如何删除git远程提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何删除由github.com托管的git远程提交?我已经在SO上找到了多个答案,显示如何删除来自分支的提交历史的提交。我尝试了这些,但是我的提交依然清晰可用,因为我可以使用它的哈希直接浏览它。

所以为了清楚起见,我的问题不是如何删除提交来自我远程的所有分支的提交历史记录。我的问题是如何删除提交本身,以便在我之前推送分支的git remote上没有记录。



我试过的解决方案包括:

删除最后一次从远程git仓库提交

回滚本地和远程git仓库1次提交



编辑:
是另一种解决方案,它不会不为我工作。这个特定的解决方案不起作用的原因是它保持git push - 强制你修改的本地分支到远程,它不会从远程删除提交,而只是从当前提交历史记录中删除它们分支。

引自GitHub支持 [1]


Github定期运行gc 。如果您希望立即从回购库中删除文件,则必须删除并重新创建回购。



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.

解决方案

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.

这篇关于如何删除git远程提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆