Git LFS (Large File Storage): thay vì lưu binary files trực tiếp trong git objects (làm repo tăng nhanh), 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: 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 migrate).
Migrate 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; skip download hoàn toàn bằng GIT_LFS_SKIP_SMUDGE=1 git clone <url> hoặc git lfs install --skip-smudge
Alternatives: Cloudinary/S3 cho media assets (không cần trong git), artifact registry cho build outputs.