How to fix git: 'lfs' is not a git command. See 'git --help'. in Git
This error occurs when Git Large File Storage (LFS) is not installed on your system. Git LFS is a separate extension that must be installed and initialized before you can use git lfs commands.
Quick fix
Fixes git: 'lfs' is not a git command. See 'git --help'.
brew install git-lfs- Install Git LFS on macOS using Homebrew
- Install Git LFS on Ubuntu/Debian
- Install Git LFS on Windows
- Install Git LFS on CentOS/RHEL/Fedora
brew install git-lfsgit: 'lfs' is not a git command. See 'git --help'.
What this error means
Git Large File Storage (LFS) is an extension to Git that replaces large files (such as audio samples, videos, datasets, and graphics) with text pointers inside Git, while storing the actual file contents on a remote server. This allows repositories to stay lightweight while still tracking large files. When you see "git: 'lfs' is not a git command," it means Git cannot find the `git-lfs` executable in your system PATH. Unlike core Git commands like `commit` or `push`, Git LFS is not bundled with Gitβit must be installed separately. This error commonly appears when cloning a repository that uses Git LFS for large files, when your CI/CD pipeline encounters LFS-tracked files, or when you try to track new large files with `git lfs track`. Without Git LFS installed, Git will not be able to download the actual contents of LFS-tracked files, leaving you with small pointer files instead.
Typical symptoms
- Running any git lfs command shows 'lfs is not a git command'
- Cloned repository contains small text pointer files instead of actual large files
- git lfs install fails with command not found
- CI/CD pipeline fails when encountering LFS-tracked files
- Error message suggests running 'git --help' to see available commands
Common causes
- Git LFS is not installed on your system (most common)
- Git LFS was installed but the git-lfs binary is not in your PATH
- On macOS: conflict between Xcode's bundled Git and Homebrew-installed Git LFS
- Git LFS installation was interrupted or incomplete
- Using a minimal Git installation that doesn't include LFS (common in containers)
- PATH environment variable not updated after installation (requires terminal restart)
How to fix "git: 'lfs' is not a git command. See 'git --help'."
The recommended way to install Git LFS on macOS is via Homebrew:
brew install git-lfsAfter installation, initialize Git LFS:
git lfs installNote: If you're using the Xcode-provided Git but Homebrew-installed git-lfs, you may need to create a symlink (see Advanced Notes).
On modern Ubuntu (21.04+) and Debian systems, install directly from the package manager:
sudo apt update
sudo apt install git-lfsFor the latest version, use the PackageCloud repository:
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfsThen initialize:
git lfs installOption 1: Using winget (Windows 10/11)
winget install -e --id GitHub.GitLFSOption 2: Using Chocolatey
choco install git-lfs.installOption 3: Reinstall Git for Windows
If you have Git for Windows installed, you can reinstall it and select "Git LFS (Large File Support)" in the "Select Components" step of the installer.
After installation, open a new terminal and run:
git lfs installImportant: Close and reopen your terminal after installation for PATH changes to take effect.
For Fedora:
sudo dnf install git-lfsFor CentOS/RHEL, first add the PackageCloud repository:
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash
sudo yum install git-lfsThen initialize:
git lfs installAfter installing, verify Git LFS is working:
git lfs versionYou should see output like:
git-lfs/3.6.0 (GitHub; linux amd64; go 1.21.3)Also verify the install hook was set up:
git lfs installExpected output:
Git LFS initialized.If Git LFS is installed but Git still can't find it, the git-lfs binary may not be in your PATH.
Find where git-lfs is installed:
which git-lfs
# or on Windows:
where git-lfsAdd to PATH (Linux/macOS):
Add the following to your shell configuration file (~/.bashrc, ~/.zshrc, or ~/.bash_profile):
export PATH="/usr/local/bin:$PATH"
# or for Homebrew on Apple Silicon:
export PATH="/opt/homebrew/bin:$PATH"Then reload your shell configuration:
source ~/.bashrc # or ~/.zshrcIf you cloned a repository before installing Git LFS, you'll have pointer files instead of actual content. After installing Git LFS, fetch the real files:
git lfs pullOr to fetch LFS files for a specific pattern:
git lfs pull --include="*.psd"To re-checkout all LFS files:
git lfs checkoutAdvanced notes
### macOS: Xcode Git vs Homebrew Git LFS Conflict
A common issue on macOS occurs when you're using the Git bundled with Xcode Command Line Tools, but Git LFS was installed via Homebrew. The two may not be aware of each other.
Solution: Create a symlink
ln -s "$(which git-lfs)" "$(git --exec-path)/git-lfs"This places the git-lfs binary in the directory where your Git installation looks for subcommands.
Alternative: Use Homebrew's Git
Install and use Homebrew's Git instead of Xcode's:
brew install gitEnsure Homebrew's bin directory is first in your PATH.
### Docker and CI/CD Environments
Many minimal container images don't include Git LFS. Add it to your Dockerfile:
Debian/Ubuntu-based images:
RUN apt-get update && apt-get install -y git-lfs && git lfs installAlpine-based images:
RUN apk add --no-cache git-lfs && git lfs install### Per-Repository vs Global Installation
Running git lfs install configures Git LFS globally for your user. To enable it only for specific repositories:
git lfs install --localThis adds the LFS hooks only to the current repository's Git configuration.
### Checking LFS Tracked Files
To see what files are being tracked by LFS in a repository:
git lfs ls-filesTo see what patterns are configured for LFS tracking:
cat .gitattributes | grep filter=lfsFrequently asked questions
- What does "git: 'lfs' is not a git command. See 'git --help'." mean?
- Git Large File Storage (LFS) is an extension to Git that replaces large files (such as audio samples, videos, datasets, and graphics) with text pointers inside Git, while storing the actual file contents on a remote server. This allows repositories to stay lightweight while still tracking large files. When you see "git: 'lfs' is not a git command," it means Git cannot find the git-lfs executable in your system PATH.
- How do I fix "git: 'lfs' is not a git command. See 'git --help'."?
- This error occurs when Git Large File Storage (LFS) is not installed on your system. Git LFS is a separate extension that must be installed and initialized before you can use git lfs commands.
- What causes "git: 'lfs' is not a git command. See 'git --help'."?
- Git LFS is not installed on your system (most common) Git LFS was installed but the git-lfs binary is not in your PATH On macOS: conflict between Xcode's bundled Git and Homebrew-installed Git LFS
- Is the "git: 'lfs' is not a git command. See 'git --help'." error serious?
- It is a medium-severity error β more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- πGit Official Documentation
- πInstalling Git Large File Storage - GitHub Docs(Official Docs)
- πInstallation - Git LFS Wiki(Official Docs)
- πGit LFS Tutorial - Atlassian(Official Docs)
- π¬git lfs is not a git command unclear - Stack Overflow(Stack Overflow)
- π¬git lfs is not a git command on macOS - Stack Overflow(Stack Overflow)
- π¬How do I install git-lfs? - Ask Ubuntu(Stack Overflow)
- π