Managing Large Files with Git LFS and git-fat
This lesson explains why large files slow Git, and how large file tools solve this.
Learning outcomes
After completing this lesson, you will be able to:
- Explain why binary files inflate repositories.
- Use Git LFS to track and migrate files.
- Explain how pipelines fetch LFS content.
- Choose between Git LFS and git-fat.
Why large files cause trouble
Git compresses text well, because it stores differences efficiently. A binary file, such as a video or compiled library, changes almost entirely from version to version and compresses poorly. Since a normal clone downloads all history, a 200 MB file changed 50 times can add 10 GB to each clone, even for developers who never open it. Build agents suffer too, as each fresh clone takes longer.
The first response is to ask whether the file belongs in Git at all. Build outputs should go to a package feed or artifact store, and dependencies should come from a package manager. Large file tools are for genuine source assets, such as design files, game assets or test data, that must be versioned with the code.
Does it belong in Git?
Git Large File Storage
Git Large File Storage (LFS) is an extension that replaces large files in a repository with small text pointers. The real content lives on an LFS server, which both Azure Repos and GitHub provide. On checkout, the Git LFS client downloads only the versions needed for the current commit, so clones stay small.
# Install the LFS hooks once per machine
git lfs install
# Track file patterns; this writes to .gitattributes
git lfs track "*.psd"
git lfs track "assets/video/**"
# Commit the tracking rules, then add files as usual
git add .gitattributes
git add assets/hero.psd
git commit -m "Add hero artwork with LFS"
git push origin main
# See which files LFS is managing
git lfs ls-filesThe .gitattributes file must be committed, since it tells every clone how to treat those paths. A pointer file in the repository looks like the following, with the real content stored elsewhere.
version https://git-lfs.github.com/spec/v1
oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f1e2a3f4b5c6d7e8f9a0b1c2d3e
size 84977953Converting existing history
git lfs track affects only new commits, so files already committed stay in history. git lfs migrate import --include="*.psd" --everything rewrites history so that past versions use pointers. As with any rewrite, commit IDs change, a force push is required, and collaborators must clone again.
Pipelines and hosting limits
Pipelines need to fetch LFS content explicitly. In Azure Pipelines, set lfs: true on the checkout step, and in GitHub Actions set lfs: true on actions/checkout. GitHub has storage and bandwidth allowances for LFS, so heavy use may incur cost, and GitHub blocks normal Git files above 100 MB. File locking, through git lfs lock, helps with binary files that cannot be merged.
The following diagram compares tracking large files with Git LFS alone with migrating the repository's history.

Git LFS problems
git-fat
git-fat is an older tool built on the same principle. It uses Git's clean and smudge filters to swap files for placeholder content on commit, and restore them on checkout. Its distinguishing feature is that content is stored on a server you control, reached through rsync, rather than on an LFS server provided by a hosting service.
A file named .gitfat gives the storage location, and .gitattributes selects file patterns with filter=fat -crlf. git fat push uploads objects and git fat pull downloads them.
# .gitfat
[rsync]
remote = storage.contoso.local:/srv/git-fat-store
# .gitattributes
*.iso filter=fat -crlfThe trade-off is clear. git-fat suits a team that must keep large content on its own storage, for example for data residency, and is willing to manage that storage and install a separate tool. It lacks the hosting integration of Git LFS, and has much less active development. For most teams on Azure Repos or GitHub, Git LFS is the recommended choice.
Git LFS or git-fat?
A slow repository
A games studio stores 30 GB of textures in an Azure Repos repository, and they have been committed directly for two years. Clones take over an hour. New textures will continue to be added and must stay versioned with the code. What should the team do?
The team should track texture patterns with Git LFS and also run git lfs migrate import to convert history, since tracking alone leaves the existing 30 GB in place. Developers must then clone again after the force push. Moving textures to a package feed would break the requirement to version them with the code, and a shallow clone would help build agents but would not improve the repository for developers who need history.
After running git lfs track, why does a clone remain large?
Show answer
Tracking affects only new commits, so old versions stay in history. git lfs migrate import rewrites history to use pointers.
Exam Tips
Remember for the exam
- Git LFS stores pointers in Git and content on an LFS server.
- git lfs track writes to .gitattributes, which must be committed.
- git lfs migrate import rewrites history for files already committed.
- Set lfs: true on checkout so that pipelines download the content.
- git-fat stores content on your own storage through rsync.