How to delete a blob from git repo

拈花ヽ惹草 提交于 2019-12-18 02:49:19

问题


I accidentally added a db dump (over 1 GB) to my repo, pushed it and noticed this few days later. I used git filter-branch to delete the file, expired reflog and run git gc to prune unused objects, but the database dump blob is still in repo. I used Which commit has this blob?, but did find any commit which has a reference to the blob. How can I delete this or how to find out why it didn't get deleted during git gc?


回答1:


Which command did you call exactly when running git gc?

Note the manpage of git gc:

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"

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

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



回答2:


Can't you just do rm .git/objects/path/to/blob?

I am not sure why git-gc didn't delete it.



来源:https://stackoverflow.com/questions/7201720/how-to-delete-a-blob-from-git-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!