【问题标题】:How to delete a commit on a git remote?如何删除 git 远程上的提交?
【发布时间】:2016-12-05 09:03:59
【问题描述】:

如何删除 github.com 托管的 git 远程上的提交?我已经在 SO 上找到了多个 answers,它们展示了如何从分支的提交历史记录中删除提交。我尝试了这些,但是我的提交仍然很明显是可用的,因为我可以使用它的哈希直接浏览它。

所以为了清楚起见,我的问题不是如何从我的遥控器上所有分支的提交历史中删除提交。我的问题是如何删除提交本身,以便在我之前将分支推送到的 git 远程上没有它的记录。

我尝试过的解决方案包括:

Remove last commit from remote git repository

Rolling back local and remote git repository by 1 commit

编辑: Git: permanently remove few commits from remote branch 是另一个对我不起作用的解决方案。这个特定解决方案不起作用的原因是因为它停留在“git push --force 你修改后的本地分支到远程。”,它不会从远程删除提交,而只会从当前的提交历史中删除它们分支。

【问题讨论】:

标签: git github git-commit


【解决方案1】:

引自“GitHub 支持”[1]:

Github 会定期运行 gc。如果您想立即从 repo 中删除文件,则必须删除并重新创建 repo。

【讨论】:

    猜你喜欢
    • 2017-01-19
    • 1970-01-01
    • 2020-09-08
    • 2013-03-26
    • 2020-07-30
    • 1970-01-01
    • 2022-07-03
    • 2020-07-29
    • 2011-01-01
    相关资源
    最近更新 更多