I'm working with a repository with a very large number of files that takes hours to checkout. I'm looking into the possibility of whether Git would work well with this kind of repository now that it supports sparse checkouts but every example that I can find does the following:
git clone <path>
git config core.sparsecheckout true
echo <dir> > .git/info/sparse-checkout
git read-tree -m -u HEAD
The problem with this sequence of commands is the original clone also does a checkout. If you add -n to the original clone command, then the read-tree command results in the following error:
error: Sparse checkout leaves no entry on working directory
How can do the sparse checkout without checking out all the files first?
Works in git v2.37.1+
git clone --filter=blob:none --no-checkout --depth 1 --sparse <project-url>
cd <project>
Specify the folders you want to clone
git sparse-checkout add <folder1> <folder2>
git checkout