Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
587 views
in Technique[技术] by (71.8m points)

version control - How to delete a blob from a Git repo

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...