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?

2

2 Answers 2

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)
Sign up to request clarification or add additional context in comments.

1 Comment

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.
1

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

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

2 Comments

When downvoting, can everyone please explain why. It helps everyone reading on a subject to learn why something is less desirable or just plain wrong. :)
Why is it safe to delete this internal Git data structure?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.