26

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 2

41

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

2 Comments

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)
I also wrote about this command in my answer here: How to shrink your .git folder in your git repo
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.