Sub topic 9
LFS Servers, Storage, and Bandwidth Limits
This chapter assumes you can clone, commit, push, and pull with Git, and that you have already tracked files with git lfs track. It explains where LFS content lives, how the client talks to the server, and which limits you are likely to hit.
Where LFS content lives
A Git remote stores commits, trees, and pointer files. The real file content goes to a separate LFS server that speaks the Git LFS API over HTTPS. Most hosts, such as GitHub, GitLab, Bitbucket, and Azure DevOps, run this server for you. Self-hosted options exist too, and the API is an open specification, so any compliant server works.
Each object is stored by its SHA-256 hash, the oid in the pointer file. Because storage is keyed by content hash, two files with identical bytes share one stored object.
version https://git-lfs.github.com/spec/v1
oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393
size 12345How the client finds the server
By default, the LFS endpoint is derived from the Git remote URL. For https://example.com/team/assets.git, the client uses https://example.com/team/assets.git/info/lfs. You can see the resolved endpoint with git lfs env.
git lfs envTo use a different server, add a .lfsconfig file to the repository root. It is committed, so everyone who clones gets the same setting.
[lfs]
url = https://lfs.example.com/team/assetsWhat happens on push
During git push, the pre-push hook sends LFS objects before the commits reach the Git remote. This ordering means a commit never references an object the server lacks.
The client first sends a batch request listing the oids it wants to upload. The server answers with a URL for each object it does not already have, and the client uploads only those. Downloads use the same batch exchange.
Storage and bandwidth limits
Hosts count two things: stored data and data transferred. The numbers differ by provider and plan, so check your host's current documentation instead of relying on figures in a tutorial.
| Limit | What it counts | What happens when exceeded |
|---|---|---|
| Storage quota | Total size of all stored LFS objects | Pushes of new objects are rejected |
| Bandwidth quota | Bytes downloaded (and sometimes uploaded) per period | Downloads fail until the quota resets or is raised |
| Maximum file size | Size of a single object | The push for that file is rejected |
Two behaviors surprise people:
- Every clone, fetch, or CI run that downloads LFS content uses bandwidth. A busy CI pipeline can use a quota quickly.
- Old versions still count. Rewriting history does not free server storage until the host deletes unreferenced objects, and some hosts only do that through a manual request or a repository deletion.
Reducing storage and transfer
- Track only files that are large and change as whole blobs. Tracking small text files adds server round trips without saving space.
- Avoid committing many revisions of a large file when one will do.
- Clone with
GIT_LFS_SKIP_SMUDGE=1and pull only what you need, as covered in the cloning chapter. - Cache LFS objects in CI instead of downloading them on every run.
- Run
git lfs prunelocally to delete cached objects that are no longer referenced by recent commits. This frees your disk, not the server's.
git lfs prune --dry-run
git lfs pruneChecking what the server holds
If a push fails with a quota or size error, git lfs ls-files --size shows the managed files and their sizes, and your host's settings page shows current usage.
git lfs ls-files --sizeExercise
A teammate rewrote history with git lfs migrate import and force-pushed, then deleted the old branch. Your host still reports the same LFS storage usage as before. Why, and what are two ways to reduce the server's stored data?
Show answer
Rewriting history changes which objects are referenced, but the old objects remain on the LFS server until the host removes unreferenced objects. Two ways to reduce usage: ask the host to run its cleanup of unreferenced LFS objects (some hosts offer this in settings or through support), or create a fresh repository from the rewritten history and delete the old one. Buying more quota raises the limit but does not lower usage.
Exercise
Where does the Git LFS client look for a custom LFS server URL that should apply to every clone of a repository, and why is that better than running git config by hand?
Show answer
In a .lfsconfig file at the repository root with an [lfs] url = ... entry. It is committed, so every collaborator gets the same endpoint automatically, whereas git config is local to one clone.