Sub topic 13
Alternatives and When Not to Use LFS
This chapter assumes you know basic Git (clone, commit, push, branches, remotes) and have read the earlier chapters on pointer files, tracking patterns, and migration. Git LFS is one answer to the large-file problem, and it is not always the right one. Here you will compare it with other approaches and learn when to skip it.
What LFS costs you
LFS moves the weight out of your repository, but it adds things you now have to manage:
- Every contributor and CI job must have the LFS client installed and enabled.
- The server must support the LFS API, and it may impose storage and bandwidth quotas.
- Clones can contain pointer files instead of real content if the smudge step is skipped or fails.
- Adopting LFS for files already in history means rewriting history with
git lfs migrate import, which changes commit IDs and needs a coordinated force push. - Removing a file from LFS later is also a history rewrite.
These costs are worth paying when large binaries are versioned alongside code. They are wasted when the files do not need versioning at all.
Alternatives
Keep the files out of Git
Build outputs, downloaded dependencies, and generated files do not belong in version control. Put them in .gitignore and rebuild them or download them when needed. This is the cheapest option and the right one for anything you can regenerate.
Artifact storage and package registries
Release binaries, installers, and compiled libraries are better served by a registry or object store such as an S3 bucket, a package registry, or your CI system's artifact storage. Git then holds only a version number or URL. You get immutable, addressable releases without storing them in Git history.
Data versioning tools
For datasets and machine learning models, tools such as DVC keep small metadata files in Git and the data in remote storage you choose. This works like LFS, but you control the storage backend, and it fits pipelines that track which data produced which model.
Partial and shallow clones
If the problem is clone time rather than the files themselves, Git has built-in features. A shallow clone limits history depth, and a partial clone with a filter avoids downloading large blobs until they are needed.
git clone --depth 1 https://example.com/team/assets.git
git clone --filter=blob:limit=1m https://example.com/team/assets.gitThe second command skips blobs over 1 MB until you check out a commit that needs them. This needs server support, and the files still live in the repository history.
Comparing the options
| Approach | Files stay versioned with code | Extra tooling | Best for |
|---|---|---|---|
| Plain Git | Yes | None | Small files, rarely changed |
| Git LFS | Yes | LFS client and server support | Design files, game assets, media |
| Artifact registry | By version reference | Registry and upload scripts | Release binaries, build outputs |
| DVC or similar | By metadata file | DVC and a storage remote | Datasets and models |
| Partial clone | Yes | Server support | Reducing clone time only |
A decision flow
When not to use LFS
Skip LFS in these cases:
- The files are small. A few images under a megabyte each are fine in plain Git. LFS adds overhead for no gain.
- The files are text that diffs well. Source code, JSON, and Markdown benefit from Git's diffs and merges. LFS stores opaque blobs, so you lose line-level diffs for those files.
- Your host or plan cannot support it. If quotas are tight or the server lacks LFS support, you may hit failed pushes or extra costs.
- Your tooling cannot run LFS. Some build systems, mirrors, or archive downloads (such as source tarballs) contain pointer files rather than real content.
- The files change constantly. Each new version of a tracked file is a new object on the server. Frequently regenerated files can use up storage quickly.
Combining approaches
The options are not exclusive. A game project might track textures with LFS, ignore build output, publish installers to a release page, and use a partial clone in CI for speed. Pick per file type, and record the choice in the repository's README so contributors know the rules.
Exercise
Your repository contains a 2 GB folder of compiled installers produced by CI on every release, plus 40 MB of Photoshop sources edited by designers. Which approach would you use for each, and why?
Show answer
Publish the installers to artifact storage or a release page, because they are build outputs that Git history does not need to keep, and store only a version reference in the repository. Track the Photoshop sources with Git LFS (optionally with locking), because they are binary files edited by hand that must stay versioned alongside the project.
Exercise
A teammate wants to put LFS on a folder of JSON configuration files because "the repo feels big." What would you check first, and what is a likely better option?
Show answer
Check what actually makes the repository large, for example by looking for big blobs in history. JSON is text that diffs and merges well, so LFS would remove those benefits. If clone time is the problem, a shallow or partial clone is a better first step. If the size comes from a few old binaries, migrate only those.