Full clone của large monorepo (Facebook-scale) có thể mất 30+ phút.
CI/CD cần tối ưu.
bash
# Shallow clone — chỉ lấy N commits gần nhất, tốt cho CI/Docker build:
git clone --depth 1 https://github.com/org/repo
# Partial (blobless) clone — tải trees, defer blobs tới khi checkout file; phù hợp nhất cho CI:
git clone --filter=blob:none https://github.com/org/repo
# Sparse checkout — chỉ checkout 1 phần của monorepo:
git clone --no-checkout https://github.com/org/monorepo && cd monorepo
git sparse-checkout init --cone
git sparse-checkout set apps/my-app packages/shared
git checkout mainTrong GitHub Actions: actions/checkout@v4 mặc định fetch-depth: 1 (shallow); đặt fetch-depth: 0 khi cần full history (semantic-release, changelog).
Treeless clone (--filter=tree:0) không tải trees — checkout gần như không dùng được, chỉ cho special cases (shallow inspection), không phải CI thông thường.
CI/CD best practice: --depth 1 + --filter=blob:none + sparse checkout = clone time giảm 90% cho large monorepos.
Lưu ý: shallow clone làm git bisect và git log --all không hoạt động đầy đủ.