Appearance
Sparse-Checkout & Partial Clone Recipes
Quick reference commands for git sparse-checkout and filtered partial clones.
1. Fast CI Single-Directory Clone
bash
# 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
bash
# 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 list3. Restore Full Working Tree
bash
# Disable sparse checkout and download all working tree files
git sparse-checkout disable4. Worktree-Specific Sparse Configurations
bash
# 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/auth5. Clean Conflicted Sparse Merges
bash
# After resolving merge conflicts in paths outside the cone
git add <conflicted-files>
git merge --continue
git sparse-checkout reapply