How to fix git-lfs not installed in CI environment in Git

GitBEGINNERMEDIUMUpdated Dec 6, 2025ยท 229 views

This error occurs when your CI/CD pipeline tries to checkout or clone a repository that uses Git LFS, but the CI runner lacks git-lfs. Configure your checkout action or install git-lfs in your pipeline script to resolve it.

Quick fix

Fixes git-lfs not installed in CI environment

- uses: actions/checkout@v4
  with:
    lfs: true
  1. Enable LFS in GitHub Actions checkout
  2. Configure GitLab CI for LFS
  3. Install git-lfs in CircleCI
  4. Set up git-lfs in Jenkins pipelines
git โ€” error
- uses: actions/checkout@v4
with:
lfs: true
git-lfs not installed in CI environment

What this error means

Git LFS (Large File Storage) is an extension that stores large binary files outside the main Git repository while keeping lightweight pointer files in the repo. When a CI/CD pipeline checks out a repository that uses Git LFS, the runner must have git-lfs installed to download the actual file contents. The "git-lfs not installed in CI environment" error occurs when: 1. The CI runner image doesn't include git-lfs by default 2. The checkout action or clone command doesn't have LFS support enabled 3. Git LFS was not installed as a build step before the checkout 4. The pipeline uses a minimal Docker image without git-lfs This error commonly appears as: - `git-lfs filter-process: git-lfs: command not found` - `This repository is configured for Git LFS but 'git-lfs' was not found on your path` - `Skipping Git LFS files` - Build failures with missing binary files or corrupt file content

Typical symptoms

  • CI pipeline fails during checkout step with git-lfs errors
  • Build artifacts are missing or contain pointer text instead of actual binary content
  • Tests fail because image, video, or data files are invalid
  • Clone operation succeeds but LFS-tracked files contain placeholder text
  • Warning messages about skipping LFS files in CI logs
  • Docker builds fail when COPY commands reference LFS-tracked files

Common causes

  1. GitHub Actions checkout@v4 action has lfs: false by default
  2. CI runner base image doesn't include git-lfs (most common)
  3. GitLab CI using an image without git-lfs installed
  4. CircleCI, Travis CI, or Jenkins using minimal executor images
  5. Custom Docker-based CI without git-lfs in the image
  6. Self-hosted runners missing git-lfs installation
  7. Azure DevOps pipelines using images without LFS support

How to fix "git-lfs not installed in CI environment"

1Enable LFS in GitHub Actions checkout

The most common fix for GitHub Actions is to enable LFS in the checkout action:

yaml
- uses: actions/checkout@v4
  with:
    lfs: true

This tells the checkout action to install git-lfs and fetch LFS files automatically.

For large repositories with many LFS files, you can also fetch only specific files:

yaml
- uses: actions/checkout@v4
  with:
    lfs: true
    # Optionally limit to specific paths
- run: |
    git lfs pull --include="assets/*"
2Configure GitLab CI for LFS

GitLab CI has built-in LFS support. Enable it by ensuring GIT_LFS_SKIP_SMUDGE is not set or set to "0":

yaml
variables:
  GIT_LFS_SKIP_SMUDGE: "0"  # Download LFS files (default)

# Or explicitly fetch LFS files in your script
build:
  script:
    - git lfs install
    - git lfs pull
    - ./build.sh

To skip LFS for faster checkout when you don't need binaries:

yaml
variables:
  GIT_LFS_SKIP_SMUDGE: "1"  # Skip LFS download for speed
3Install git-lfs in CircleCI

CircleCI images may not include git-lfs. Install it before checkout:

yaml
version: 2.1

jobs:
  build:
    docker:
      - image: cimg/base:stable
    steps:
      - run:
          name: Install Git LFS
          command: |
            curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
            sudo apt-get install git-lfs
            git lfs install
      - checkout
      - run:
          name: Fetch LFS files
          command: git lfs pull

Alternative using the machine executor:

yaml
jobs:
  build:
    machine:
      image: ubuntu-2204:current  # Has git-lfs pre-installed
    steps:
      - checkout
      - run: git lfs pull
4Set up git-lfs in Jenkins pipelines

For Jenkins, install git-lfs on the agent or add it to your pipeline:

groovy
pipeline {
    agent any
    stages {
        stage('Setup') {
            steps {
                sh '''
                    # Install git-lfs if not present
                    if ! command -v git-lfs &> /dev/null; then
                        curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
                        sudo apt-get install -y git-lfs
                    fi
                    git lfs install
                '''
            }
        }
        stage('Checkout') {
            steps {
                checkout scm
                sh 'git lfs pull'
            }
        }
    }
}

For Docker-based Jenkins agents, ensure your Dockerfile includes git-lfs:

dockerfile
FROM jenkins/agent:latest
RUN apt-get update && apt-get install -y git-lfs && git lfs install
5Configure Azure DevOps pipelines

Azure Pipelines checkout can be configured for LFS:

yaml
steps:
- checkout: self
  lfs: true
  fetchDepth: 0  # Full history for LFS references

# Or use the Git LFS task
- task: Bash@3
  displayName: 'Install Git LFS'
  inputs:
    targetType: 'inline'
    script: |
      curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
      sudo apt-get install git-lfs
      git lfs install
      git lfs pull

For Microsoft-hosted agents, git-lfs is typically pre-installed. Use lfs: true in checkout.

6Add git-lfs to custom Docker images

If your CI uses custom Docker images, add git-lfs to your Dockerfile:

Debian/Ubuntu-based:

dockerfile
FROM ubuntu:22.04
RUN apt-get update && \
    apt-get install -y git curl && \
    curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \
    apt-get install -y git-lfs && \
    git lfs install && \
    rm -rf /var/lib/apt/lists/*

Alpine-based:

dockerfile
FROM alpine:3.18
RUN apk add --no-cache git git-lfs && \
    git lfs install

Amazon Linux / RHEL-based:

dockerfile
FROM amazonlinux:2023
RUN yum install -y git && \
    curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | bash && \
    yum install -y git-lfs && \
    git lfs install
7Install git-lfs in Travis CI

Travis CI supports git-lfs configuration in .travis.yml:

yaml
git:
  lfs_skip_smudge: false  # Download LFS files (default)

# Or install manually for more control
before_install:
  - git lfs install
  - git lfs pull

To skip LFS for speed:

yaml
git:
  lfs_skip_smudge: true

For macOS builds:

yaml
os: osx
before_install:
  - brew install git-lfs
  - git lfs install
  - git lfs pull
8Set up self-hosted runners with git-lfs

For self-hosted GitHub Actions runners, GitLab runners, or other self-managed CI infrastructure:

Install git-lfs on the runner machine:

bash
# Ubuntu/Debian
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
sudo git lfs install --system  # System-wide installation

# macOS
brew install git-lfs
git lfs install

# Windows (run as Administrator)
winget install GitHub.GitLFS
git lfs install

Verify installation:

bash
git lfs version
git lfs env

For GitLab runners, ensure the runner's executor has git-lfs available. For Docker executors, use an image with git-lfs installed.

9Verify the fix in your CI pipeline

Add verification steps to your pipeline to confirm LFS is working:

yaml
# GitHub Actions example
- name: Verify Git LFS
  run: |
    echo "Git LFS version:"
    git lfs version

    echo "LFS-tracked files:"
    git lfs ls-files

    echo "LFS status:"
    git lfs status

    # Verify a specific LFS file exists and isn't a pointer
    if head -c 100 path/to/large-file.bin | grep -q "^version https://git-lfs"; then
      echo "ERROR: LFS file contains pointer, not actual content"
      exit 1
    fi
    echo "LFS files downloaded successfully"

This ensures your build won't proceed with broken LFS content.

Advanced notes

### Caching LFS Files in CI

LFS downloads can be slow. Cache them to speed up builds:

GitHub Actions:

yaml
- name: Cache LFS files
  uses: actions/cache@v4
  with:
    path: .git/lfs
    key: lfs-${{ hashFiles('.gitattributes') }}
    restore-keys: lfs-

- uses: actions/checkout@v4
  with:
    lfs: true

GitLab CI:

yaml
cache:
  key: lfs-cache
  paths:
    - .git/lfs

build:
  script:
    - git lfs pull

### Partial Clone to Skip LFS Entirely

If you don't need LFS files in CI (e.g., for linting or tests that don't use binaries):

yaml
# GitHub Actions
- uses: actions/checkout@v4
  with:
    lfs: false  # Skip LFS entirely

# Set environment to prevent warnings
- run: git config lfs.fetchexclude "*"

### Troubleshooting LFS in Docker Builds

When building Docker images that need LFS files:

dockerfile
# Bad: LFS files won't be real content
COPY . /app

# Good: Ensure LFS is pulled before build
# In your CI, run: git lfs pull
# Then build the Docker image

Or use multi-stage builds with LFS:

dockerfile
FROM alpine:3.18 AS lfs-fetch
RUN apk add --no-cache git git-lfs
WORKDIR /repo
COPY .git .git
COPY .gitattributes .
RUN git lfs install && git lfs pull

FROM node:20-alpine
COPY --from=lfs-fetch /repo /app

### LFS Bandwidth and Rate Limits

CI/CD pipelines can exhaust LFS bandwidth quotas. Monitor usage:

- GitHub: Check Settings > Billing > Git LFS data
- GitLab: Check Group/Project Settings > Usage Quotas
- Bitbucket: Check Workspace Settings > Plan details

Consider using git lfs fetch --recent to only download recently updated LFS files.

### Alternative: Store Large Files Elsewhere

For very large files or high-bandwidth CI scenarios, consider:
- Storing binaries in artifact storage (S3, GCS, Azure Blob)
- Using a separate CDN for large test fixtures
- Mounting shared NFS/EFS volumes in CI runners

Frequently asked questions

What does "git-lfs not installed in CI environment" mean?
Git LFS (Large File Storage) is an extension that stores large binary files outside the main Git repository while keeping lightweight pointer files in the repo. When a CI/CD pipeline checks out a repository that uses Git LFS, the runner must have git-lfs installed to download the actual file contents. The "git-lfs not installed in CI environment" error occurs when: 1.
How do I fix "git-lfs not installed in CI environment"?
This error occurs when your CI/CD pipeline tries to checkout or clone a repository that uses Git LFS, but the CI runner lacks git-lfs. Configure your checkout action or install git-lfs in your pipeline script to resolve it.
What causes "git-lfs not installed in CI environment"?
GitHub Actions checkout@v4 action has lfs: false by default CI runner base image doesn't include git-lfs (most common) GitLab CI using an image without git-lfs installed
Is the "git-lfs not installed in CI environment" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading