How to delete a blob from git repo

前端 未结 2 1120
南笙
南笙 2020-12-15 13:03

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

相关标签:
2条回答
  • 2020-12-15 13:12

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

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

    0 讨论(0)
  • 2020-12-15 13:17

    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)
    
    0 讨论(0)
提交回复
热议问题