如何从GitHub中删除一个悬而未决的提交? [英] How to remove a dangling commit from GitHub?

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

问题描述

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



现在,GitHub同时提交了:

>

>

我的主分支只跟踪第二次提交,但第一次提交仍然可用,并且仍在我的活动提要中。我怎样才能删除它,以确保没有人意外地提交那个提交而不是更正的版本?

解决方案

GitHub会定期垃圾收集无法从顶层引用(例如标签或分支或reflog)到达的任何提交(和其他对象)。这意味着随着时间的推移(比如下个月),这个对象将会消失。



拉应该生成一个只包含被引用的对象的包,所以没有人应该得到作为克隆或拉的结果提交。例如,

  $ git clone git://github.com/nylen/connectbot.git 
克隆到connectbot ...
remote:计数对象:6261,完成。
remote:压缩对象:100%(1900/1900),完成。
remote:共计6261(delta 3739),重用5980(delta 3520)
接收对象:100%(6261/6261),3.04 MiB | 3.40 MiB / s,完成。
解决三角洲问题:完成100%(3739/3739)。
$ git cat-file -t 1cd775d
致命错误:不是有效的对象名称1cd775d

如果您确实需要立即将其删除,您可能需要联系 GitHub支持


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:

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?

解决方案

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.

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

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