Saturday, 21 June 2025

Git Large File Storage (LFS)

One of my hobby projects is using big files. Github complains about it:

remote: warning: File mrbear/Terrain_PureNature.asset is 58.17 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: GH001: Large files detected. You may want to try Git Large File Storage1 - https://git-lfs.github.com.

Luckily this is only a warning. The real error happens when trying to push 2GB or bigger files onto the github2.

So, after installing it on my system...

brew install git-lfs

And telling git I wish to use it:

git lfs install

I had to tell it which files were the primary culprits (apparently we do not want ALL files to use LFS).

git lfs track ".png"
git lfs track ".asset"
git lfs track ".fbx"
git lfs track ".unity"

Let's not forget to add those new settings to the repo.

git add Assets/.gitattributes

Apparently this will only work on new files. Existing files in the repo are not changed.

But your could try the command git-lfs-migrate (which will change your repos history) for existing files3.

Addendum

I think it can be argued that, if you need to use LFS a lot for your git repo, git might actually not be the right tool for you.

But I'll leave that argument to smarter people.

References

[1] Git Large File Storage (LFS)
https://git-lfs.github.com
[2] GitHub - About Git Large File Storage
https://docs.github.com/en/repositories/working-with-files/managing-large-files/about-git-large-file-storage
[3] Github Blog - Git LFS 2.2.0 released
https://github.blog/open-source/git/git-lfs-2-2-0-released/

No comments:

Post a Comment