Git LFS is an open source Git extension for versioning large files (e.g. audio, video, and graphics) with Git by replacing these large files with text pointers that are tracked by Git, while storing the file contents on a remote server like GitHub.
This extension is really useful when working on a project with large files that are updated frequently, such as assets in a game project. It allows us to keep the repository size small while still being able to version the large files, meaning faster cloning and pulling of the repository. We also don’t need to worry about cleaning up the repository history to remove the large files after they are no longer needed.
We do have to keep in mind that Git LFS needs a remote server to store the large files, so we’re fully dependent on the server for their availability, storage, and bandwidth. If you rarely or never update the large files, then you can ignore this extension knowing you’re not missing out on anything.
To install Git LFS, we can run the following command…
git lfs install
Then we can track the large files (we’re using “mp4” files as an example here) by running…
git lfs track "*.mp4"
This will add or generate a
.gitattributes file that you’ll need to track and commit. Commit the rest of the changes, push it, and you’re done!
To uninstall Git LFS, we can run the following command…
git lfs uninstall
Then go to your
.gitattributes file and remove the lines that were added by Git LFS (if it’s everything, then you can safely delete the file)
# examples this file might have
-*.mp4 filter=lfs diff=lfs merge=lfs -text
-*.png filter=lfs diff=lfs merge=lfs -text
-*.jpg filter=lfs diff=lfs merge=lfs -text
-*.jpeg filter=lfs diff=lfs merge=lfs -text
Re-track and add the files that were previously tracked by Git LFS by running…
git add --renormalize .
commit the changes, push it, and you’re done!
- https://git-lfs.com/ - Git Large File Storage Website
- https://docs.github.com/en/repositories/working-with-files/managing-large-files - Managing large files in GitHub