git lfs Command: Large Files in CI
git lfs (Large File Storage) replaces big files with pointers and fetches their content on demand.
When a repo uses LFS, a plain clone gives you pointer text files instead of real assets. CI must initialize LFS and pull the objects, or the build sees placeholder files.
Common flags
install- set up the LFS hooks and filters for the user or repoinstall --local- install hooks only for the current repositorypull- download LFS objects and replace pointers in the working treefetch- download LFS objects without updating the working treecheckout- populate working-tree files from already-fetched objectsenv- print LFS configuration for debugging
Example
# Ensure LFS assets are real files, not pointers, in CI
git lfs install --local
git lfs pullIn CI
If a build fails because an image or binary is a tiny text file starting with "version https://git-lfs", LFS was not pulled. Run git lfs install then git lfs pull (or set lfs: true in your checkout action). Caching LFS objects between runs avoids re-downloading large assets.
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.
- 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 detachedKey takeaways
- Without git lfs pull, CI sees pointer files instead of real large assets.
- git lfs install sets up the filters; git lfs pull fetches the content.
- A text file starting with "version https://git-lfs" is an unpulled pointer.