Skip to content

Instantly share code, notes, and snippets.

@pawlik
Created April 8, 2015 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawlik/cdc279c3ef44aad76805 to your computer and use it in GitHub Desktop.
Save pawlik/cdc279c3ef44aad76805 to your computer and use it in GitHub Desktop.
When full clone is too long - make a cache. You can run it with `watch -n 1 ./git-cache.sh git@github.com:Username/RepoName`, it will create cached version on /tmp/git-cache/git@github.com:Username/Reponame so you can clone new repos from there. Good when you make many clones and it's slow. Add apriopriate remotes when needed.
cache_dir="/tmp/git-cache/"
if [ ! -d "$cache_dir" ]
then
mkdir -p $cache_dir
fi
cache_path=$cache_dir$1
if [ ! -d "$cache_path" ]
then
git clone --mirror $1 $cache_path
else
echo "cache seems to exist already, go with the update\n"
cd $cache_path
git remote update
fi
echo "your cache is available and updated at $cache_path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment