Git Large File Storage (LFS) is an extension to Git that allows you to version control large files efficiently. Instead of storing large files directly in your Git repository, LFS stores only a small pointer file in the repo while the actual file contents are stored on a separate LFS server.
- Prevents repository bloat: Large files don't inflate your
.gitfolder size - Faster cloning: Initial clones download pointers, not full file contents
- Version control for large data: Track changes to datasets, figures, and other large files
- Automatic handling: Once configured, LFS works transparently
-
Git for Windows installer
- Download and install from: https://git-scm.com/download/win
-
Verify installation
git lfs version
You should see output like:
git-lfs/3.x.x
After installing Git LFS, run this command once on your machine:
git lfs installThis sets up the necessary Git hooks to make LFS work automatically.
This repository is already configured for Git LFS via the .gitattributes file.
The following directory is tracked by LFS:
01_data/03_large_files_LFS/**(all files in this folder)
Copying this template into an existing repo? Make sure .gitattributes comes across too. A repo created on GitHub may already have its own default .gitattributes (containing only * text=auto), and that file has no LFS rule. Without the LFS rule, files in the large files folder are committed as regular Git files, and GitHub rejects any file over 100 MB on push.
To confirm LFS will pick up a file before committing:
git check-attr filter -- "01_data/03_large_files_LFS/my_file.csv"
# Expected: filter: lfs (if "unspecified", the LFS rule is missing)- Ensure Git LFS is installed (see Installation section above)
If you're using this as a template and need to set up a new repo:
-
Initialize Git (if not already initialized)
git init
-
Ensure
.gitattributesexists- This template includes it already
- It specifies which files should use LFS
-
Add and commit your files normally
git add . git commit -m "Initial commit with LFS tracking"
-
Add remote and push
git remote add origin <repository-url> git push -u origin main
Simply add files to the 01_data/03_large_files_LFS/ directory and commit normally:
Git LFS handles everything automatically - no special commands needed!
# See which commits modified LFS files
git log --follow -- "01_data/03_large_files_LFS/my_file.csv"- GitHub: 2 GB per file, 1 GB free storage per account If you exceed limits, you may need to purchase additional LFS storage or use alternative solutions.
- Small files (< 1 MB): Regular Git handles these efficiently
- Files that change frequently: LFS stores every version, so rapidly changing files accumulate storage
- Temporary files: These should be in
.gitignoreinstead
- Large datasets (.csv, .rds, .parquet files)
Your LFS storage limit has been exceeded. Options:
- Purchase additional storage from your Git provider
- Remove large files from history using
git lfs prune - Use external storage (cloud storage) and reference via URLs
Run the installation steps above, then:
git lfs install
git lfs pull# Manually fetch LFS files
git lfs pull# Check if file is an LFS pointer
git lfs ls-files | grep "filename"
# Or examine the file directly
cat "01_data/03_large_files_LFS/myfile.csv" | head -5If it shows version https://git-lfs.github.com/spec/v1, it's an LFS pointer.
- Official Documentation: https://git-lfs.github.com/
- GitHub LFS Guide: https://docs.github.com/en/repositories/working-with-files/managing-large-files
- Atlassian Tutorial: https://www.atlassian.com/git/tutorials/git-lfs
Once Git LFS is installed and configured (one-time setup), it works quietly:
- Add files to
01_data/03_large_files_LFS/ - Commit and push normally
- Git automatically handles LFS routing
- Collaborators automatically get large files when they clone/pull