← Back to Git Course | Chapter 10: Tools & Internals | Lesson 6 of 8

Git Large File Storage (LFS)

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?

bash
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

bash
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

bash
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

bash
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

bash
git clone https://github.com/user/repo.git

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.