Sub topic 9
LFS Servers, Storage, and Bandwidth Limits
This chapter assumes you can clone, commit, push, and pull with Git. It also assumes you have already tracked files with git lfs track and seen pointer files. Here you learn where LFS content lives, how Git LFS talks to the server that holds it, and how storage and bandwidth limits affect your work.
Two stores behind one remote
A repository that uses LFS has two kinds of data on the server side:
- The Git objects: commits, trees, and the small pointer files.
- The LFS objects: the real file contents, each stored under its SHA-256 hash.
Git itself only transfers the first kind. The git-lfs client transfers the second kind over a separate HTTP-based protocol called the Batch API. The two stores can live on the same host or on different hosts.
During git push, a pre-push hook installed by git lfs install runs first. It uploads the LFS content, and only then does Git send the commits. This order matters. A pointer file never reaches the remote before the content it refers to.
How the client finds the LFS server
The client looks for the LFS endpoint in this order:
- The
lfs.urlsetting in.lfsconfigor.git/config. - The
remote.<name>.lfsurlsetting. - A URL derived from the Git remote URL by appending
/info/lfs.
For a remote at https://example.com/team/assets.git, the default LFS endpoint is https://example.com/team/assets.git/info/lfs. Most hosting services use this default, so you rarely need to configure anything.
You can see what the client resolved with:
git lfs envThe output includes Endpoint=, the access mode, and the local storage paths. Check this first whenever uploads or downloads go to an unexpected place.
Sharing a custom endpoint with a team
If your team runs its own LFS server, commit a .lfsconfig file at the repository root so everyone gets the same endpoint:
[lfs]
url = https://lfs.example.com/team/assets.lfsconfig uses the same syntax as Git config files. The client only reads a limited set of keys from it, because a file that arrives with a clone should not be able to change security-sensitive settings. Keep credentials out of this file.
Authentication
LFS uses the same credentials as your Git remote in most cases, through your configured credential helper. Over SSH, the client runs git-lfs-authenticate on the server to obtain a short-lived HTTPS token. Authentication problems usually show up as HTTP 401 or 403 errors during upload or download, and they are separate from Git's own authentication.
Where content lives on your machine
Locally, LFS stores objects inside .git/lfs/objects, organized by the first four characters of the hash:
.git/lfs/objects/4d/7a/4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393The working tree holds a second copy of each file you have checked out. So a 1 GB file occupies roughly 1 GB in the cache and 1 GB in the working tree. Keep this in mind on small disks and CI runners.
Because objects are named by their hash, identical content is stored once. Renaming a file or reverting to an older version does not create a new LFS object if the content already exists.
Cleaning up the local cache
Old versions accumulate in .git/lfs/objects. To remove those that are not referenced by recent commits or unpushed work, run:
git lfs prune --dry-run
git lfs pruneUse --dry-run first to see what would be deleted. By default, prune keeps the current checkout, recent commits, and anything not yet pushed. You can tune the retention window with lfs.fetchrecentrefsdays and lfs.fetchrecentcommitsdays. Pruned objects can be downloaded again from the server, as long as the server still has them.
Choosing a server
| Option | Who runs it | Typical use |
|---|---|---|
| GitHub, GitLab, Bitbucket, Azure DevOps | Hosting provider | Most teams. LFS is built in and uses the same permissions as the repository. |
| Self-hosted GitLab, Gitea, or similar | Your team | Data must stay on your own infrastructure. |
| Standalone LFS server | Your team | Git hosting and large-file storage are on separate systems. |
Hosted services handle the Batch API, storage, and access control for you. Self-hosted setups give you control over where files live and what they cost, and they add operational work: backups, disk or object-storage capacity, and upgrades.
Permissions follow the repository. If someone can read the repository, they can usually download its LFS objects. If someone can push, they can upload.
Storage and bandwidth limits
Hosting services meter LFS separately from regular Git data. Limits differ between providers and change over time, so read your provider's current documentation before relying on any figure. The concepts are the same everywhere.
- Storage quota. The total size of all LFS objects kept on the server. Every version of every file counts, not just the latest.
- Bandwidth quota. The amount of LFS data downloaded per month. Every clone, fetch, or CI checkout that downloads LFS content consumes it.
- Per-file size limit. The largest single object the server accepts. A push containing a larger file fails.
GitHub, for example, has historically included a free allowance of storage and monthly bandwidth for LFS and sells additional data packs, and it enforces a maximum file size that depends on the plan. Treat those details as an example of how limits are structured, and confirm the numbers yourself.
What counts against your quota
Several habits consume quota faster than people expect:
- Fresh clones in CI. A pipeline that downloads 2 GB of LFS content on every run uses 2 GB of bandwidth per run. Fifty runs a day is 100 GB a day.
- Forks. On some hosts, a fork shares objects with its parent, and on others downloads from a fork are charged to the parent. Check how your host handles this.
- Many versions of a large file. Ten saved revisions of a 500 MB file is 5 GB of stored data, because LFS does not diff binaries.
- Rewritten history. After
git lfs migrate importand a force push, the old objects may remain on the server. On many hosts they only free up after garbage collection or manual deletion.
Reducing bandwidth use
You can lower consumption without changing what your team versions:
- Cache
.git/lfsbetween CI runs, keyed on a hash of the pointer files or.gitattributes. - Download only the paths a job needs, using
git lfs pull --include. - Skip LFS downloads on jobs that do not read the files by setting
GIT_LFS_SKIP_SMUDGE=1for the checkout. - Fetch from a nearby mirror or an internal cache when your host or server supports one.
Deleting data to recover space
Removing a file from the latest commit does not free server storage. Earlier commits still reference the object, so it stays. To reclaim space you generally need to:
- Rewrite history so no commit references the object.
- Force push the rewritten branches and tags.
- Ask the host to delete or garbage-collect unreferenced LFS objects, or use the host's own admin tools.
Some providers only reclaim space after you delete and recreate the repository. This is disruptive, so decide early what belongs in LFS. Checking the cost of a file before you track it is cheaper than removing it later.
Checking what a push will send
You can estimate how much data will move before you push. List the LFS files in the current checkout with sizes:
git lfs ls-files --sizeAnd show which objects are waiting to upload for the current branch:
git lfs statusRun these before a large push on a metered plan. They help you spot a build artifact or a full dataset that was tracked by mistake.
Failure modes
| Symptom | Likely cause | What to check |
|---|---|---|
| `batch response: This repository is over its data quota` | Storage or bandwidth quota is exhausted | Provider's usage page. Buy more quota, prune old objects, or wait for the monthly reset. |
| `Git LFS: (0 of 1 files) ... 413` or a similar size error | A file exceeds the per-file limit | Your plan's maximum object size. Split the file or move it outside Git. |
| `401` or `403` during download | Credentials or permissions are wrong | `git lfs env`, your credential helper, and whether you have read access. |
| `Object does not exist on the server` | Pointer was pushed without its content, or the object was deleted | Run `git lfs push --all origin` from a clone that still has the object. |
| Pointer files in the working tree | The smudge step was skipped | Run `git lfs pull`. |
The fourth row happens when a pointer reaches the remote through a path that bypassed the pre-push hook, such as a push made with --no-verify or from a machine where git lfs install was never run. Fix it by pushing the missing content from any clone that has it:
git lfs push --all originSummary of the model
Git stores pointers. The LFS server stores content, indexed by SHA-256. Limits apply to what the server holds, to what it sends out, and to the size of each object. Every version you commit stays stored until history is rewritten and the server cleans up. Plan for that before you track a new file type.
Exercise
Your team's CI pipeline checks out a repository with 3 GB of LFS content and runs 40 times a day. The provider's bandwidth quota is 50 GB per month. Estimate the monthly bandwidth use and name two changes that would reduce it.
Show answer
About 3 GB x 40 runs x 30 days = 3,600 GB per month, far over the 50 GB quota. Two changes: cache .git/lfs between runs so unchanged objects are not downloaded again, and use git lfs pull --include (or skip LFS downloads with GIT_LFS_SKIP_SMUDGE=1) in jobs that do not need all the files.
Exercise
You delete a 2 GB video from your repository in a new commit and push it. Your storage usage on the server does not change. Why, and what steps are needed to reclaim the space?
Show answer
Earlier commits still reference the video's LFS object, so the server keeps it. To reclaim the space, rewrite history so no commit references the object, force push the rewritten branches and tags, and then have the host garbage-collect or delete unreferenced LFS objects.