pre-commit "check-added-large-files" fails in CI
The check-added-large-files hook from pre-commit-hooks flags any file over its size threshold (default 500 KB). In CI it fails because a large artifact or binary was committed to the repo.
What this error means
The hook prints "Failed" and names a file with its size, for example "app.bin (1234 KB) exceeds 500 KB".
check for added large files.................................Failed
- hook id: check-added-large-files
- exit code: 1
data/model.bin (5321 KB) exceeds 500 KB.Common causes
A large binary or artifact was committed
A build output, dataset, or media file over the limit was added to git and the hook catches it.
The default threshold is lower than intended
A legitimately larger asset trips the default 500 KB limit that was never raised for the repo.
How to fix it
Remove the large file or track it with LFS
- Remove the oversized file from git history or move it to Git LFS.
- Add it to
.gitignoreif it is a build artifact. - Re-run so the hook passes.
git rm --cached data/model.bin
git lfs track "data/*.bin"Raise the limit deliberately if needed
If larger files are expected, set an explicit maxkb via args.
- id: check-added-large-files
args: ['--maxkb=1024']How to prevent it
- Ignore build artifacts so they are never committed.
- Use Git LFS for legitimately large assets.
- Set an explicit
--maxkbthat matches your repo policy.