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.
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.
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 checkout### 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=lfskex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server
fatal: unable to access: Proxy auto-configuration failed
How to fix 'Proxy auto-configuration failed' in Git
fatal: unable to access: Authentication failed (proxy requires basic auth)
How to fix 'Authentication failed (proxy requires basic auth)' in Git
fatal: unable to access: no_proxy configuration not working
How to fix 'no_proxy configuration not working' in Git
fatal: unable to read tree object in treeless clone
How to fix 'unable to read tree object in treeless clone' in Git