Git LFS Cheat Sheet

Git Large File Storage — manage large binary files in Git repositories. Track, migrate, lock, and optimize workflows for assets and datasets.

Last Updated: May 1, 2025

Getting Started

git lfs install
Install Git LFS hooks in your repository (once per user)
git lfs track '*.psd'
Track Photoshop files with LFS
git lfs track '*.zip' '*.mp4'
Track multiple file types at once
git lfs track 'data/*.csv'
Track large CSV files in data/ directory
git add .gitattributes
Commit the .gitattributes file with LFS rules
git lfs ls-files
List all files currently tracked by LFS
git lfs status
Show which files are properly tracked vs pointers

Working with LFS

git add file.psd && git commit
LFS automatically intercepts tracked file types
git push origin main
Push normally — LFS files go to LFS server
git lfs fetch
Download LFS files (run after clone if needed)
git lfs pull
Fetch and checkout LFS files for current ref
git lfs fetch --all
Download ALL LFS objects (can be very large)
git lfs prune
Delete old LFS files no longer referenced

File Locking (Prevent Conflicts)

git lfs lock file.psd
Lock a binary file to prevent concurrent edits
git lfs unlock file.psd
Release the lock after editing
git lfs locks
List all currently locked files
git lfs unlock --force file.psd
Force-unlock (admin override)
git lfs track --lockable '*.psd'
Mark files as lockable in .gitattributes

Migration & Best Practices

ItemDescription
Install Before CloneAlways run git lfs install before cloning LFS repos
Track EarlySet up LFS tracking before adding large files to history
Migrate ExistingUse git lfs migrate import to move existing files to LFS
Hosting LimitsGitHub: 2GB free, GitLab: 10GB per repo — check limits
CI/CDInstall git lfs in CI pipelines before checkout step
Git AttributesLFS rules go in .gitattributes — commit this file
Pointer FilesLFS replaces files with small pointer text files in Git objects
When NOT to UseDon't use LFS for files under ~5MB — Git handles those fine
Pro Tip: Install Git LFS before cloning a repo that uses it, or your binary files will be pointers (tiny text files) — not the actual assets.