Downloading only part of a git repo, e.g one subfolder, is called a sparse checkout, or sparse clone
The steps to do a sparse checkout are as follows:
- Start with an empty git repository:
git init <repo_name>
- Enter that directory:
cd <repo_name>
- Configure the remote repo address:
git remote add -f origin <url_of_remote_repo>
- Configure git to enable sparse:
git config core.sparsecheckout true
- Configure git, to define which files and folders should actually be downloaded by adding them, one per line, in .git/info/sparse-checkout:
echo some/dir/ >> .git/info/sparse-checkout
echo another/sub/tree >> .git/info/sparse-checkout
- Pull from the the remote repo:
git pull origin master