Skip to content

Instantly share code, notes, and snippets.

@seancribbs
Created August 22, 2012 16:26
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seancribbs/3427201 to your computer and use it in GitHub Desktop.
Save seancribbs/3427201 to your computer and use it in GitHub Desktop.

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.

  1. Create a bare git repository in some directory, e.g. /var/lib/gitcache.

    git init --bare /var/lib/gitcache
  2. 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
  3. Fetch all the remotes. This takes a while, and should be run periodically.

    git fetch --all
  4. When cloning, refer to the cache repository:

    git clone --reference /var/lib/gitcache git://github.com/rails/rails.git
  5. Now you have lightning-fast clones!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment