In this brief article, I will cover the basics of Git Large File System, short for Git-LFS.
Its use case is, as the name suggests, to allow uploading large files (over 100 MB – to be precise) to your GitHub Repository. You might need to push design files to your repository (for documentation purposes, or to keep everything related to a project in one place), or you might be a game developer, in which case, there are dozens of files with a size that is north of the limit.
How it Works – Theory
In essence, the large files are still not stored within the GitHub repository. Git-LFS works by uploading the large files to the cloud and store a pointer with the location of that file in your GitHub Repository.
brew install git-lfs # for mac
Commands to know
- If you do not wish to add the large files to your GitHub repository, you can simply add them to the .gitignore file. As a basic example, let us say you wish to prevent all the zip files in your local repository from being tracked/uploaded to the remote repository, you would add the following line in your .gitignore file:
- If you do wish to track the large files, then you can either add those files individually or in bulk. The bulk is particularly useful when most of your files over 100 MB are divided into a few different extensions. For instance, you might have 15 PSD files and 10 zip files.
- Navigate to the project directory in terminal/command prompt and run the below commands:
git lfs install git lfs track *.psd
- That’s it. Add, commit and push your changes to the remote repository like you normally would and the error won’t appear.