Git LFS (Large File Storage): thay vì lưu binary files trực tiếp trong git objects (làm repo phình to), LFS lưu pointer nhỏ trong git, còn actual file lưu trên LFS server riêng.
Setup:
bash
# Install:
brew install git-lfs # macOS
git lfs install
# Track file patterns:
git lfs track "*.psd"
git lfs track "*.figma"
git lfs track "*.mp4"
git lfs track "*.zip"
git lfs track "dist/**" # build artifacts
# Commit .gitattributes:
git add .gitattributes
git commit -m "chore: configure Git LFS tracking"
# Push (LFS files upload automatically):
git push origin mainKiểm tra files đang track:
bash
git lfs ls-files # files đang trong LFS
git lfs status # pending uploads
git lfs migrate info # phân tích files lớn chưa migrateMigrate history cũ vào LFS:
bash
git lfs migrate import --include="*.psd" --everything
git push --force --all # cần force push vì history rewriteCân nhắc:
- GitHub: 1GB LFS storage miễn phí, sau đó tính phí bandwidth
- CI/CD: cần cấu hình để pull LFS files (GIT_LFS_SKIP_SMUDGE=1 git clone <url> để skip LFS download hoàn toàn)
- Clone: git lfs install --skip-smudge cũng có thể dùng — --no-local KHÔNG liên quan đến LFS
Alternatives: Cloudinary/S3 cho media assets (không cần trong git), artifact registry cho build outputs.