Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: reduce the size of `.git/lfs/`

Tags:

git

git-lfs

I use git-lfs to track large files, the setup is:

.
├── ...
├── ...
├── large-files
├── ...
├── ...
└── .git

where an external storage is mounted on large-files, and all large files go here.

The problem with this setup is, there is a .git/lfs directory, which uses the same amount disk spaces as the large-files, since I will never delete from large-files, and my SSD, where the working tree resides, has smaller capacity than the external storage, .git/lfs will outgrow my SSD's capacity.

Is there a way to reduce the size of this .git/lfs without moving it to an external storage? (putting .git or the entire working tree to the external storage is not an option, because the external storage is not always available)

like image 296
Incömplete Avatar asked Jun 21 '18 06:06

Incömplete


People also ask

Does git LFS reduce size?

Git LFS does not compress files. Some files are compressible, and some are not. It, like Git's partial clone feature, is designed to offload most of the data to a trusted server for the purposes of making local access lighter and cheaper.

How do I make git smaller?

remove the file from your project's current file-tree. remove the file from repository history — rewriting Git history, deleting the file from all commits containing it. remove all reflog history that refers to the old commit history. repack the repository, garbage-collecting the now-unused data using git gc.

What size files should go in git LFS?

There is currently a 10 GB size limit for the file upload into the media storage. Uploading files larger than 10 GB will result in an error. Use the Git LFS extension with a repository to speed up the handling of large files. Use the Git Large File Storage (LFS) extension with an existing Bitbucket Cloud repository.

What is git LFS prune?

DESCRIPTION. Deletes local copies of LFS files which are old, thus freeing up disk space. Prune operates by enumerating all the locally stored objects, and then deleting any which are not referenced by at least ONE of the following: ○ the current checkout.


1 Answers

.git/lfs is the local cache directory for git-lfs, Git Large File Storage. It keeps the repository size down by storing the history of large files in cloud storage instead of in local history.

.git/lfs will not grow indefinitely. It's normal for git-lfs to cache "recent" versions of large files there. You can run git lfs prune to have it prune the cache, and you can configure how much it prunes with lfs.pruneoffsetdays and lfs.fetchrecent.

You can also put this directory elsewhere by changing lfs.storage.

like image 69
Schwern Avatar answered Sep 28 '22 19:09

Schwern