Since git 1.7.0 it is possible to use a technique called sparse checkout
The steps for cloning are:
Mkdir<repo></repo> Cd<repo></repo> git init git remote add -f origin<url></url>
This creates an empty folder, runs the fetches but without checking out the files. Then you have to configure git to use sparseCheckout.
git config core.sparseCheckout true
Then you have to define which folders/files should be present. To do this you have to add them in the file .git/info/sparse-checkout. For example:
echo "some/dir/" .git/info/sparse-checkout
echo "another/sub/tree" - .git/info/sparse-checkoutOnce this is done, you have to update the folder:
git sweater origin master