git-cache-clone is a drop-in wrapper for git clone that accelerates repository cloning by using a local cache. It's designed to optimize CI pipelines and repetitive local workflows by avoiding redundant network fetches.
- Fast
git clonevia--reference - Subcommands for
clone,clean,refresh,add,info - Handles concurrent operations on cache entries via file locks
- Managed cache directory
- Safe and explicit cache cleanup
- URL normalization to avoid duplicate cache entries
pip3 install git-cache-cloneVarious subcommands are available. When no subcommand is provided, clone is assumed.
git cache clone- Clone a repository using the cache; adds to cache if missinggit cache add- Add a repository to the cache manuallygit cache clean- Remove cached repositoriesgit cache refresh- Rungit fetchon cached repositoriesgit cache info- Show details on cache contents
By default,
git-cache-clone accepts its own options and subcommands. To pass arguments directly to the underlying git command, you must use --. Everything after -- is forwarded verbatim.
git cache clone <url> -- --depth=1
git cache refresh <url> -- --unshallowgit cache clone --depth=1 <url>
git cache refresh --unshallow <url>
Run git cache -h to see all available subcommands and their options.
Some widely used configurations can be set via environment variables and git config:
| Env Variable | Git Config Key | Type | Valid Values / Description | Default |
|---|---|---|---|---|
GIT_CACHE_ROOT_DIR |
gitcache.rootdir |
path |
working directory of git-cache-clone | ~/.local/share/git-cache |
GIT_CACHE_USE_LOCK |
gitcache.uselock |
bool |
true, 1, y, yes |
true |
GIT_CACHE_LOCK_TIMEOUT |
gitcache.locktimeout |
number |
timeout in seconds to wait for a lock | -1 |
GIT_CACHE_CLONE_MODE |
gitcache.clonemode |
string |
bare, mirror |
bare |
GIT_CACHE_METADATA_STORE_MODE |
gitcache.metadatastoremode |
string |
sqlite, json, none |
sqlite |
When resolving configuration values, git-cache-clone applies the following precedence, from highest to lowest:
-
Command-line arguments
-
Environment variables
-
Git configuration (git config)
-
Built-in defaults
- Python 3.6+
- Git installed and available in PATH
MIT License