10

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

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Maciej Lotkowski
  • 642
  • 1
  • 6
  • 10
  • 1
    Would http://stackoverflow.com/questions/2116778/reduce-git-repository-size/2116892#2116892 help? or http://stackoverflow.com/questions/1029969/why-is-my-git-repository-so-big? – VonC Aug 26 '11 at 08:13
  • Re *"did find any commit"*: Do you mean *"didn't find any commit"* (the opposite)? – Peter Mortensen Aug 31 '21 at 01:18

2 Answers2

15

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)
dunni
  • 43,386
  • 10
  • 104
  • 99
  • Thanks, I didn't notice pruneExpire option and was't aware that git keeps unrefererenced objects for some time. Previously, I did run git gc --prune --aggressive. Now, I did run git reflog --all --expire=now before git gc --prune and it deleted the blob. – Maciej Lotkowski Aug 26 '11 at 09:31
1

Just do rm .git/objects/path/to/blob.

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Chaitanya Gupta
  • 4,043
  • 2
  • 31
  • 41