From Git 1.7 it is possible to checkout specific files from a repository. The feature in Git is called sparse checkout.
Create a repository:
git init myRepo
where myRepo is the directory to create the new repository.
Go into the repository and tell it will use the sparse checkout feature:
cd myRepo
git config core.sparseCheckout true
Create a file called sparse-checkout in .git/info/:
vi .git/info/sparse-checkout
Add all the files you want to checkout using repository root as the starting point. For example:
vagrant-digitalocean/Vagrantfile
Add the remote repository address. For example using one of my Github repositories:
git remote add -f origin git@github.com:dannytsang/example.git
Change git@github.com:dannytsang/example.git to your repository.
Set the branch:
git checkout master
The above should automatically pull the files down for only the specified files. Otherwise perform a git pull.
It’s not as easy to setup but once complete it makes it very easy to maintain.
Is it possible to do a sparse checkout without checking out the whole repository first?