Last Updated: May 1, 2025
Getting Started
git lfs installInstall 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 .gitattributesCommit the .gitattributes file with LFS rules
git lfs ls-filesList all files currently tracked by LFS
git lfs statusShow which files are properly tracked vs pointers
Working with LFS
git add file.psd && git commitLFS automatically intercepts tracked file types
git push origin mainPush normally — LFS files go to LFS server
git lfs fetchDownload LFS files (run after clone if needed)
git lfs pullFetch and checkout LFS files for current ref
git lfs fetch --allDownload ALL LFS objects (can be very large)
git lfs pruneDelete old LFS files no longer referenced
File Locking (Prevent Conflicts)
git lfs lock file.psdLock a binary file to prevent concurrent edits
git lfs unlock file.psdRelease the lock after editing
git lfs locksList all currently locked files
git lfs unlock --force file.psdForce-unlock (admin override)
git lfs track --lockable '*.psd'Mark files as lockable in .gitattributes
Migration & Best Practices
| Item | Description |
|---|---|
Install Before Clone | Always run git lfs install before cloning LFS repos |
Track Early | Set up LFS tracking before adding large files to history |
Migrate Existing | Use git lfs migrate import to move existing files to LFS |
Hosting Limits | GitHub: 2GB free, GitLab: 10GB per repo — check limits |
CI/CD | Install git lfs in CI pipelines before checkout step |
Git Attributes | LFS rules go in .gitattributes — commit this file |
Pointer Files | LFS replaces files with small pointer text files in Git objects |
When NOT to Use | Don'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.