Git LFS
Learn how to handle large files with Git Large File Storage
Git LFS
Git Large File Storage (LFS) replaces large files with text pointers inside Git, while storing the file contents on a remote server.
Installation
# Install Git LFS
git lfs install
# Initialize LFS in repository
git lfs track "*.psd"
git lfs track "*.zip"
git lfs track "*.mp4"
Basic Usage
Track File Types
# Track specific file types
git lfs track "*.pdf"
git lfs track "*.mov"
git lfs track "images/*.jpg"
# Track specific files
git lfs track "large-dataset.csv"
Working with LFS Files
# Add and commit as normal
git add .gitattributes
git add large-file.zip
git commit -m "Add large file with LFS"
git push origin main
Common Commands
View LFS Status
# Show LFS files
git lfs ls-files
# Show tracking patterns
git lfs track
# Show LFS status
git lfs status
Download LFS Files
# Download all LFS files
git lfs pull
# Download specific LFS files
git lfs pull --include="*.mp4"
Best Practices
- Track large binary files (>100MB)
- Add
.gitattributes
to version control - Use meaningful file patterns
- Document LFS usage in README
Common File Types for LFS
# Images and media
git lfs track "*.jpg"
git lfs track "*.png"
git lfs track "*.mp4"
git lfs track "*.mov"
# Archives and packages
git lfs track "*.zip"
git lfs track "*.tar.gz"
git lfs track "*.dmg"
# Design files
git lfs track "*.psd"
git lfs track "*.ai"
git lfs track "*.sketch"