GitHub 源代码视图显示不再存在的提交

发布于 2024-11-16 23:16:11 字数 770 浏览 3 评论 0原文

两周前我重写了 GitHub 存储库的历史(rebase 和一些樱桃精选),并通过强制将其推回 GitHub

git push -f origin master

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

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

现在我的问题。我的存储库的 GitHub 源代码视图至少显示了一项由于我重写历史记录而不应再存在的提交。事实上,它不存在于我的本地或 GitHub 的提交日志中(但它是我本地引用日志的一部分)。如何删除远程 GitHub 存储库中的此提交以及其他可能的提交?有没有办法清理远程存储库并删除那些不属于提交日志的“无法访问”提交?

顺便说一句,如果我克隆 GitHub 存储库,克隆中不存在恶意提交。 git show 返回 fatal: bad object

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

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

提前致谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄人书 2024-11-23 23:16:11

提交不会由于重写历史记录而从存储库中默默地消失,它们只是不再被引用

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

正如您通过克隆检查的那样,提交不再可达。理论上,它最终应该被垃圾收集,但正如您所观察到的,这可能不会很快发生 - 也许永远不会发生。 (是否有人从您链接的另一个问题中提到的提交中分叉出来,这会阻碍垃圾收集?)

如果“错误”提交中存在任何机密数据,请联系 github 支持人员将其删除。如果没有,只需忽略提交 - 它放在存储库中并没有什么坏处。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文