Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git LFS - How to remove older versions of files from a git repository?

Tags:

git

I have a Git repository with several huge files. I am using Git LFS for large file support.

Today I received an email saying

Git LFS has been disabled on your personal account.... 

Current usage as of 19 May 2019 06:12AM UTC:

Bandwidth: 0.0 GB / 1 GB (0%)
Storage: 6.16 GB / 1 GB (616%)

The repository certainly does not have files of 6.26GB. However, possibly Git is adding up storage due to the older versions of file.

Can you help me how do I remove the previous version of files, only keeping the latest?

like image 499
Rahul Avatar asked Nov 17 '22 08:11

Rahul


1 Answers

My problem is related, but not exactly the same.

I'm using JFrog Artifactory for Git LFS. We have plentiful storage, so storing past versions is not a problem on our "origin".

The problem is with the clone on my PC. I don't need all past versions there - but they pile up every time I push or pull. This takes up space in the .git\lfs\objects folder in the clone - and indeed filled up my drive!

As Aaron Voelkner pointed out in the answer, I can run git-lfs prune and it drastically reduces the amount of data stored locally.

$ git-lfs prune
prune: 2914 local object(s), 975 retained, done.
prune: Deleting objects: 100% (1939/1939), done.

If I wanted to look at older versions, I can still get them via origin, but this makes my local working much simpler.

like image 134
NickBeaugié Avatar answered Jan 01 '23 05:01

NickBeaugié