This is a distillation of a technique we use internally at Basho to reduce the pain of cloning some of our larger repos. It relies a bit on shell scripts and environment variables, but it can be run more directly, as I show below.
-
Create a bare git repository in some directory, e.g.
/var/lib/gitcache
.git init --bare /var/lib/gitcache
-
Add all repositories you want to cache as remotes to the git repository, e.g.
cd /var/lib/gitcache git remote add rails/rails git://github.com/rails/rails.git
-
Fetch all the remotes. This takes a while, and should be run periodically.
git fetch --all
-
When cloning, refer to the cache repository:
git clone --reference /var/lib/gitcache git://github.com/rails/rails.git
-
Now you have lightning-fast clones!