如何从 Git 存储库中删除 blob [英] How to delete a blob from a Git repo

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

问题描述

我不小心在我的存储库中添加了一个数据库转储(超过 1 GB),推送它并在几天后注意到这一点.

I accidentally added a database dump (over 1 GB) to my repository, pushed it and noticed this few days later.

我使用 git filter-branch 删除文件,使 reflog 过期并运行 git gc 来修剪未使用的对象,但数据库转储 blob 仍在存储库中.我使用了哪个提交有这个 blob?,但我确实找到了任何引用 blob 的提交.我该如何删除它,或者我如何找出在 git gc 期间它没有被删除的原因?

I used git filter-branch to delete the file, expired reflog and ran git gc to prune unused objects, but the database dump blob is still in the repository. I used Which commit has this blob?, but I did find any commit which has a reference to the blob. How can I delete this or how do I find out why it didn't get deleted during git gc?

推荐答案

你在运行 git gc 时到底调用了哪个命令?

Which command did you call exactly when running git gc?

注意 git gc 的联机帮助页:

Note the manpage of git gc:

可选的配置变量 gc.pruneExpire 控制未引用的松散对象在修剪之前必须保持多长时间.默认为2 周前"

The optional configuration variable gc.pruneExpire controls how old the unreferenced loose objects have to be before they are pruned. The default is "2 weeks ago"

因此,如果您的 blob 小于 14 天,则必须致电

So if your blob is younger than 14 days, you have to call

git gc --prune=<date> (for date you also can insert now)

这篇关于如何从 Git 存储库中删除 blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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