关于github:我可以从远程存储库中获取所有git对象吗?

Can I fetch all git objects from a remote repository?

我从本地计算机上丢失了一些代码,我认为我在github存储库中有对象,问题是,它们悬空了对象,我不知道如何获取它们,有没有办法获取它们?

这是所有事情的发生方式(包括我的愚蠢):

我有一个存储库,其中包含一些巨大的SQL数据(回购大约为300M),因为存储库的大小使git clone变慢,所以我继续删除了巨大的文件。

git filter-branch 'git rm ...'之后,我修复了依赖于已删除数据的测试,并编写了一些代码,然后提交了更改并将它们git push --force origin放入github中。

当我尝试使用这个"新"存储库进行基础调整时,它只是在表面上感觉到了。 git filter-branch 'git rm ...'更改了第一次提交,因此一切都变成了冲突。

因为我无法变基,所以我决定尝试其他方法,因此从本地计算机上删除了存储库,然后从旧存储库中备份了git push --force到github中。

那是我失去一些工作的方式。

我认为这些对象仍在github中,因为它们有关如何删除敏感数据的文章说:

This article tells you how to make commits with sensitive data unreachable from any branches or tags in your GitHub repository. However, it's important to note that those commits may still be accessible in any clones or forks of your repository, directly via their SHA-1 hashes in cached views on GitHub, and through any pull requests that reference them. You can't do anything about existing clones or forks of your repository, but you can contact support to permanently remove all of your repository's cached views and pull requests with the offending commits.


该注释仅告诉您,由于无法识别的克隆或分叉,您可能还有整个项目的其他副本。

如果是这样,则您很幸运-验证它是否确实未被触碰,然后只需将未触动的存储库推送到您的遥控器即可。

如果您没有运气,我建议您按照以下步骤操作:

  • 制作完整的深层副本(它必须包含您的repoistory-folder的.git作为备份。
  • 阅读有关数据恢复的那一章和这篇文章,并尝试不同的策略来恢复数据。如果出现严重故障,请再次从备份中进行复制。
  • 无论您在何处阅读,都请避免git gc