In a recent project of mine (Flutter + Unity) some very large files had to be exported from Unity into the app?s project directory and therefore were also part of the project repository.
Ideally a Git repository shouldn?t contain very large files. But sometimes there?s just no other (practical) way than keeping these files in the project repository. While versioning these files in the local repository worked just fine I was blocked from pushing my commits to the remote with a message like this:
remote: error: File ios/UnityExport/Libraries/libiPhone-lib.a is 572.03 MB; this exceeds GitHub?s file size limit of 100.00 MB
Even after working with Git for already eight years it was only today that I realized and experienced that there are file size and/or repository size limitations on Git hosting platforms like GitHub or Bitbucket.
Fortunately there?s a ?workaround? for this limitation. Or in other words, a recommended way to work with large files and repositories. It?s called Git Large File Storage, an open source Git extension for versioning large files.
?Git Large File Storage (LFS) replaces large files such as audio samples, videos, datasets, and graphics with text pointers inside Git, while storing the file contents on a remote server [?].?
Or as Atlassian?s defines it:
?Git LFS (Large File Storage) is a Git extension developed by Atlassian, GitHub, and a few other open source contributors, that reduces the impact of large files in your repository by downloading the relevant versions of them lazily. Specifically, large files are downloaded during the checkout process rather than during cloning or fetching.?
To start versioning large files you only have to follow these simple steps:
- Download and install the Git LFS command line extensions for your OS.
- Setup Git LFS for your user account:
git lfs install
3. Configure Git LFS to track your large files:
git lfs track “*.xyz”
4. Add, commit and push your large files as any other files.
For further and in-depth information on Git LFS I recommend you to have a look at the following sources:
- Git LFS Tutorial (git-lfs wiki)
- Managing large files (GitHub Help)
- Git LFS (Atlassian Tutorials)