Git LFS (Large File Storage) is a Git extension for versioning large files like images, videos, datasets, and binaries. Instead of storing these files directly in Git, LFS stores pointers in the repository and the actual files on a remote server.
winget install GitLFS
Or download from git-lfs.github.com
brew install git-lfs
sudo apt-get install git-lfs
git lfs install
Tell Git which files to track with LFS:
# Track all PSD files
git lfs track "*.psd"
# Track all MP4 files
git lfs track "*.mp4"
# Track all files in a directory
git lfs track "assets/*"
# Track specific large file
git lfs track "dataset.csv"
This creates or updates .gitattributes file:
*.psd filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
# Add .gitattributes
git add .gitattributes
# Add your large files
git add large-file.psd
# Commit
git commit -m "Add large file with LFS"
# Push (LFS files uploaded automatically)
git push origin main
git lfs track
git lfs ls-files
git lfs status
# Pull all LFS files
git lfs pull
# Pull specific branch
git lfs pull origin feature-branch
git lfs fetch --all
LFS is enabled by default in gityar. To verify:
LFS files are stored in:
data/lfs/
Configure storage limits in app.ini:
[repository.upload]
LFS_MAX_FILE_SIZE = 104857600 # 100MB
LFS_MAX_STORAGE = 10737418240 # 10GB per repository
Use git lfs migrate:
# Migrate all PSD files
git lfs migrate import --include="*.psd"
# Migrate multiple file types
git lfs migrate import --include="*.psd,*.mp4,*.zip"
# Migrate and rewrite history
git lfs migrate import --include="*.psd" --everything
⚠️ Warning: Rewriting history changes commit hashes!
git push --force
.gitattributes updated"LFS objects not found":
git lfs fetch --all
git lfs checkout
"Insufficient disk space":
git lfs prune"Authentication failed":
Slow clone/pull:
git clone --depth 1GIT_LFS_SKIP_SMUDGE=1 git clonegit lfs pullIf files show as pointers instead of actual content:
# Download LFS files
git lfs pull
# Verify file
git lfs fsck
Remove old LFS objects:
# Preview what will be deleted
git lfs prune --dry-run
# Delete old objects
git lfs prune
| Command | Description |
|---|---|
git lfs install |
Initialize LFS |
git lfs track |
Track file patterns |
git lfs ls-files |
List LFS files |
git lfs status |
Show LFS status |
git lfs pull |
Download LFS files |
git lfs fetch |
Fetch LFS objects |
git lfs push |
Push LFS objects |
git lfs prune |
Clean old objects |
git lfs migrate |
Migrate files to LFS |
git lfs fsck |
Verify LFS objects |