# Git LFS objects re-downloaded every run (no cache) in CI

> Fix Git LFS objects being re-downloaded on every CI run - without caching .git/lfs, each job re-fetches the same blobs, wasting bandwidth quota and time.

Source: https://latchkey.dev/learn/command-reference/git-lfs-cache-objects-in-ci  
Updated: 2026-06-30

Every CI job that checks out with LFS re-downloads the objects unless `.git/lfs` is cached. This is slow and burns the monthly bandwidth allowance, and can lead to quota 429s on busy repos.

## Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

```.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### What causes Git LFS objects re-downloaded every run (no cache) in CI?

There are 2 common causes: no cache for the lfs object store and a cache key that never hits. The .git/lfs directory is not cached, so each run starts with an empty object store and re-fetches everything.

### How do I fix Git LFS objects re-downloaded every run (no cache) in CI?

There are 2 fixes depending on which cause you have: cache .git/lfs with a stable key and fetch only needed objects. Work through them in order, since the first is the most common.

### What does Git LFS objects re-downloaded every run (no cache) in CI actually mean?

CI logs show the same LFS objects downloading on every run, jobs are slow at checkout, and LFS bandwidth usage climbs quickly.

### How do I stop Git LFS objects re-downloaded every run (no cache) in CI happening again?

Cache .git/lfs with a key tied to the object set. The prevention section lists 3 changes that keep it from recurring.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
