GitHub源视图显示不再存在的提交 [英] GitHub Source view shows commit that does no longer exist

查看:148
本文介绍了GitHub源视图显示不再存在的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两周前重写了一个GitHub仓库的历史(rebase和一些樱桃选择),然后通过

 <$将其推回给GitHub c $ c> git push -f origin master 

一切都很顺利,至少看起来是这样的 git log 显示了正确的提交历史记录。我知道,重写历史记录是不好的做法,但是存储库是新的,我是唯一的用户,所以不应该有其他人遇到任何麻烦。

我的存储库有只有一个分支,名为 master



现在是我的问题。我的存储库的GitHub的Source视图显示至少有一个提交由于我的历史重写而不再存在。事实上它不存在于我的本地或GitHub的提交日志中(但它是我本地reflog的一部分)。我该如何摆脱这个提交以及可能位于我的远程GitHub存储库中的其他提交?有没有什么办法清理远程仓库,并删除那些不属于提交日志的不可访问提交?



顺便说一句,如果我克隆GitHub仓库,流氓提交不在克隆中。 git show< SHA1> 返回致命:bad object

我的问题与 SO 4367977 非常相似,但该问题的解决方案等待GitHub的垃圾回收显然不起作用。提交链接在6个月后仍然有效。

删除存储库并重新创建它应该可以解决这个问题,但这不是很优雅。



提前致谢!

解决方案

提交不会默默消失由于重写历史记录,他们只是不再引用



推送到存储库意味着上传对象列表,然后设置一些标签和或分支到一些提交。它并不意味着从目标库中删除任何未被分支使用的提交(和其他对象)。



当你通过克隆检查,提交不再可用。从理论上讲,它最终应该被垃圾收集,但正如你所观察到的,这可能不会很快发生 - 也许永远不会发生。 (可能是有人从你链接的其他问题中提到的提交中分离出来的,这会阻碍垃圾回收?)

如果错误中有任何机密数据提交,请联系github支持以删除它。如果没有,只需忽略提交 - 它在存储库中不会有任何伤害。


I rewrote the history of a GitHub repository two weeks ago (rebase and some cherry-picks) and force pushed it back to GitHub via

git push -f origin master

Everything went fine, at least it looked that way and git log showed the correct commit history. I know, rewriting history is bad practice, but the repository is new and I'm the only user, so there should not be any troubles for others.

My repository has only one branch, named master.

Now to my problem. GitHub's Source view of my repository shows at least one commit that should no longer exist due to my rewriting of history. And indeed it does not exist in my local nor in GitHub's commit log (but it is part of my local reflog). How do I get rid of this commit and possibly others that are in my remote GitHub repository? Is there any way to clean up a remote repository and delete those "unreachable" commits that are not part of the commit log?

BTW if I clone the GitHub repository, the rogue commit is not present in the clone. git show <SHA1> returns fatal: bad object.

My question is very similar to SO 4367977 but the solution to that question "waiting for GitHub's garbage collection" did obviously not work. The commits-links still work after 6 months have passed.

Deleting the repository and recreating it should solve the problem but this it not very elegant.

Thanks in advance!

解决方案

Commits do not silently disappear from a repository due to rewriting history, they just get not referenced any more.

Pushing to a repository means uploading a list of objects and then setting some tags and or branches to some commit. It does not mean remove any commits (and other objects) from the target repository that are not used by the branches as now.

As you checked by cloning, the commit is not reachable anymore. In theory, it should be garbage collected eventually, but as you observed, this may not happen soon - maybe never. (Could it be that someone forked from the commit mentioned in the other question you linked, and this hinders garbage collection?)

If there is any confidential data in the "wrong" commit, contact the github support to remove it. If not, simply ignore the commit - it does no harm sitting there in the repository.

这篇关于GitHub源视图显示不再存在的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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