Sparse-Checkout & Partial Clone Recipes¶
Quick reference commands for git sparse-checkout and filtered partial clones.
1. Fast CI Single-Directory Clone¶
# Blobless shallow clone with targeted directory population
git clone --filter=blob:none --no-checkout --depth 1 <REPO_URL> workspace
cd workspace
git sparse-checkout init --cone
git sparse-checkout set <DIR_PATH_1> <DIR_PATH_2>
git checkout <BRANCH>
2. Existing Repository: Shrink to Sparse Set¶
# Switch existing repository to cone mode
git sparse-checkout init --cone
# Restrict working directory to specific services
git sparse-checkout set services/billing infrastructure/terraform
# Append an additional directory
git sparse-checkout add packages/shared-types
# Verify active cone directories
git sparse-checkout list
3. Restore Full Working Tree¶
4. Worktree-Specific Sparse Configurations¶
# Enable multi-worktree config isolation
git config extensions.worktreeConfig true
# Create worktree and isolate cone
git worktree add ../service-auth-wt feature/auth-refactor
cd ../service-auth-wt
git sparse-checkout init --cone
git sparse-checkout set services/auth