Git Large File Storage (LFS)
In this page:
What is Git LFS?
Git is designed for text files. Storing large binary files (like videos, datasets, or graphics) slows down cloning. Git LFS (Large File Storage) replaces these files with lightweight, 1KB text pointer files in your repository, keeping clone speeds fast on servers like cookiescursor.com.
Example: What is Git LFS?
git lfs install
Tracking Large Files
git lfs track "*.psd" (or any glob pattern) registers a file type to be handled by LFS, writing the rule into a .gitattributes file that's itself committed to the repo — so once one person sets it up, everyone who clones the project gets the same LFS behavior automatically.
Example: Tracking Large Files
git lfs track "*.psd"
git add .gitattributes
Staging and Committing LFS Files
With tracking configured, git add and git commit work exactly as normal — LFS intercepts matching files behind the scenes, uploads their actual content to LFS storage, and commits a small pointer file (containing the file's hash and size) to the regular Git history in its place.
Example: Staging and Committing LFS Files
git add design.psd
git commit -m "Add design file"
Checking LFS Status
git lfs ls-files lists which tracked files in your working directory are currently managed by LFS, and git lfs status shows which of those have pending changes — useful for confirming a large file is actually being routed through LFS and not accidentally committed as a regular blob.
Example: Checking LFS Status
git lfs ls-files
git lfs status
Cloning LFS Repositories
When cloning a repository that uses LFS, Git downloads the lightweight pointers first, then automatically fetches the actual large files from the LFS storage server. This keeps the cloning process fast and efficient.
Example: Cloning LFS Repositories
git clone https://github.com/user/repo.git
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: