如何从 GitHub 中删除悬空提交? [英] How to remove a dangling commit from GitHub?

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

问题描述

昨天,我推送到我在 GitHub 上的 ConnectBot 分支.我推送了一次,意识到我没有按照我想要的方式进行更改,重新提交并再次推送.

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.

现在,GitHub 有两个提交:

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?

推荐答案

删除repo或联系GitHub

如果您能承受丢失所有问题,那么在没有错误提交的情况下删除存储库并重新创建它似乎是可行的.数据也会从提交 API 中消失(尽管推送事件仍然可见).另请参阅:https://stackoverflow.com/a/32840254/895245

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

如果您无法承受丢失问题数据,GitHub 支持可以手动删除悬空提交.例如,当我将所有 GitHub 提交电子邮件上传到仓库时,他们问我把它取下来,所以我做了,他们做了一个 gc.包含数据的拉取请求 有然而被删除:由于这个原因,在最初删除后一年内仍可访问存储库数据.

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.

他们目前的 帮助页面说:

您可以联系 GitHub 支持,永久删除所有存储库缓存视图和 GitHub 上的拉取请求.

you can permanently remove all of your repository's cached views and pull requests on GitHub by contacting GitHub Support.

也许将 repo 设为私有也会保留问题并摆脱提交,我不确定.不过你肯定会失去开始/分叉.不确定还原后提交是否会消失.但至少您可以保留问题的私人备份.

Maybe making the repo private will also keep the issues around and get rid of the commit, I'm not sure. You lose starts/forks for sure though. Not sure if after restore the commits will be gone or not. But at least you might be able to keep a private backup of issues.

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

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