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:
# 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:
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:
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.
Git LFS (Large File Storage): instead of storing binary files directly in git objects (which bloats the repo), LFS stores a small pointer in git while the actual file lives on a separate LFS server.
Setup:
# 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 mainInspect tracked files:
git lfs ls-files # files currently in LFS
git lfs status # pending uploads
git lfs migrate info # analyze large files not yet migratedMigrate old history into LFS:
git lfs migrate import --include="*.psd" --everything
git push --force --all # force push required due to history rewriteConsiderations:
- GitHub: 1GB LFS storage free, then bandwidth is billed
- CI/CD: configure to pull LFS files (GIT_LFS_SKIP_SMUDGE=1 git clone <url> to skip LFS downloads entirely, or git lfs install --skip-smudge)
- git clone --no-local does NOT skip LFS — it only forces a network clone instead of hard-linking local objects
Alternatives: Cloudinary/S3 for media assets (no need in git), artifact registries for build outputs.