Starting with Git 2.37.0 there are a lot of improvements, particularly the full integration and rollout of sparse index. Using partial checkouts can really help the speed of git commands, among others committing, amending, stashing and querying status. This guide is to be considered experimental, so please don't modify/destroy your main repo checkout. A personal recommendation: use a sparse worktree
Note: the sparse-checkout.txt
file mentioned below is a simple newline separated list of relative directories within the repository.
git clone --no-checkout "ssh://git@github.com/path/to/repo.git" sparse-repo
cd sparse-repo
git sparse-checkout init --cone --sparse-index
git sparse-checkout set --stdin <<< $(cat sparse-checkout.txt)
git checkout main
cd main-repo-dir
git worktree add ../sparse-repo --no-checkout
cd sparse-repo
git sparse-checkout init --cone --sparse-index
git sparse-checkout set --stdin <<< $(cat sparse-checkout.txt)
git checkout <branch>
Converting a worktree or repository to sparse breaks powerlevel10k/gitstatus integration.
References