Git LFS (Large File Storage)
Learn Git LFS (Large File Storage) to keep big binary assets out of your repository history using lightweight pointers. Setup and commands included.
Definition
Git LFS (Large File Storage) is an extension that keeps large binary files — videos, datasets, design assets, game art — out of your Git history. Instead of storing a 500 MB file in the repository, Git LFS stores a tiny text pointer and keeps the real content in a separate LFS store. The result: clones stay fast and the repository stays small, even when the project ships gigabytes of assets.
Why large files hurt Git
Git is built for text and stores the full history of every file. Commit a big binary a few times and every clone must download every version of it forever — even versions nobody needs. History balloons, clones crawl, and pushes time out. Git LFS sidesteps this by versioning a small pointer instead of the heavy content.
Setup
Install the extension once per machine, then initialize it in a repository:
git lfs installTell LFS which files to manage by tracking patterns. This writes rules into .gitattributes:
git lfs track "*.psd"
git lfs track "*.mp4"
git add .gitattributesFrom now on, matching files are stored through LFS automatically. Commit and push as usual:
git add design.psd
git commit -m "Add hero design source"
git pushGit uploads the pointer to the repository and the binary content to the LFS store.
What a pointer looks like
In the repository, the tracked file is replaced by a small text pointer that records the content's hash and size:
version https://git-lfs.github.com/spec/v1
oid sha256:9af1c2...
size 471859200When someone checks out the file, Git LFS uses this pointer to fetch the real content on demand.
Common commands
| Command | Description |
|---|---|
git lfs install | Enables LFS for your user (run once). |
git lfs track "<pattern>" | Starts managing files matching a pattern via LFS. |
git lfs untrack "<pattern>" | Stops managing a pattern. |
git lfs ls-files | Lists the files currently tracked by LFS. |
git lfs pull | Downloads the LFS content for the current checkout. |
git lfs migrate | Rewrites existing history to move large files into LFS. |
Things to know
LFS requires server support — GitHub, GitLab, and Bitbucket all provide it, sometimes with storage quotas. Anyone cloning the repository must also have Git LFS installed, or they will receive the pointer text instead of the real file. For brand-new large files this is seamless; to move files that are already committed into LFS, use git lfs migrate.
Practice
How does Git LFS keep repositories small?