Git LFS "files that should have been pointers, but weren't" in CI
A file that a .gitattributes pattern tracks with LFS was committed as its real bytes instead of a pointer. git lfs detects the mismatch and the pre-push hook or a CI check refuses to proceed.
What this error means
A push or a git lfs status check fails with "Encountered N file(s) that should have been pointers, but weren't" and lists the offending paths.
Encountered 2 file(s) that should have been pointers, but weren't:
assets/logo.psd
data/sample.parquet
error: failed to push some refs to 'https://github.com/acme/app.git'Common causes
Files were committed before LFS tracking was added
The .gitattributes rule was added after the files were already staged as content, so the real bytes are in history, not pointers.
A commit bypassed the LFS clean filter
Committing with LFS not installed, or with the filter disabled, stores the file content directly even though a track pattern matches it.
How to fix it
Re-import the paths as pointers
- Confirm the pattern in
.gitattributesmatches the listed files. - Rewrite the matching files into pointers with
git lfs migrate import. - Force-push the rewritten history and re-run CI.
git lfs migrate import --include="*.psd,*.parquet" --everything
git push --force-with-leaseFix a single working copy without a rewrite
For files not yet pushed, touch and recommit them so the clean filter converts them to pointers.
git rm --cached assets/logo.psd
git add assets/logo.psd
git commit -m "Store logo.psd via LFS"How to prevent it
- Add
.gitattributesLFS rules before committing matching files. - Verify
git lfsis installed on every machine that commits. - Add a CI
git lfs statuscheck to catch raw content early.