I have a project with a lot of binaries (mostly pdfs) that I'm using git-lfs with. The project is about 60mb but I found that my .git/lfs/objects directory is about 500mb. I presume these are cached versions of previous commits. Is there a way to gracefully delete them without corrupting the state of git? The odds of me ever wanting previous versions of the files in LFS are near zero, now that the project is over.
2 Answers
I found the git-lfs man pages. It turns out there is a git lfs prune command which does exactly what I needed:
C:\Path\to\project [master]> du -h -d 0 625M . C:\Path\to\project [master]> git lfs prune * 101 local objects, 88 retained Pruning 13 files, (393.8 MB) * Deleted 13 files C:\Path\to\project [master]> du -h -d 0 231M . 2 Comments
orzechow
Interesting, in my version of git-lfs no prune is mentioned in the man pages, but the command works!
git-lfs/1.5.6 (GitHub; linux amd64; go 1.7.4)Gabriel Staples
I also wrote about this command in my answer here: How to shrink your .git folder in your git repo
For me the accepted solution of git lfs prune didn't help at all. However running git lfs dedup command as proposed in another question allowed to free 200Gb of space