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 director is about 500mb. I presume these are cached versions of previous commits. Is there a way to gracefully delete these (ie delete them without corrupting the state of git)? The odds of me ever wanting previous versions of the files in LFS are near 0 now especially since the project is over.
Asked
Active
Viewed 1.2k times
1 Answers
33
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 .

user1816847
- 1,877
- 3
- 17
- 29
-
1Interesting, 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)` – orzechow Apr 19 '17 at 09:17
-
I also wrote about this command in my answer here: [How to shrink your .git folder in your git repo](https://stackoverflow.com/questions/5613345/how-to-shrink-the-git-folder/68554906#68554906) – Gabriel Staples Sep 21 '21 at 00:31