Create empty repository and add origin without checkout:
mkdir <repo>
cd <repo>
git init
git remote add -f origin <url>
Set sparse checkout:
git config core.sparseCheckout true
Define which folders to check out in .git/info/sparse-checkout
eg:
echo "some/dir/" >> .git/info/sparse-checkout
echo "another/sub/tree" >> .git/info/sparse-checkout
Then pull files from repository.
git pull origin master
You might want to include .gitignore
files in your sparse-checkout -file, since the root files are not pulled from repository.
Instructions modified from a post in stackoverflow