Download less
If a build doesn’t need the full history, a shallow or partial clone transfers far less data.-
A shallow clone fetches only the latest commit:
-
A partial clone fetches the full history but downloads file contents only when a checkout needs them:
actions/checkout already makes a shallow clone by default (fetch-depth: 1). Only raise it if a step needs history, such as one that compares against another branch.
Abort stalled transfers so they retry
A transfer that slows to a crawl rarely recovers, but a new connection usually runs at full speed. Instead of waiting for a stalled clone, abort it and try again. How you do that depends on whether you clone over HTTPS or SSH.HTTPS clones
Git can abort an HTTPS transfer that stays below a minimum speed. For example, this aborts a transfer that stays under about 200 KB/s for 60 seconds:http.lowSpeedLimit is in bytes per second. Set it below the speed your normal clones reach, so a slow but healthy clone isn’t cut off.
SSH clones
Thehttp.lowSpeedLimit and http.lowSpeedTime settings don’t apply to SSH clones. Limit how long the clone can take instead:
-
Use your CI tool’s timeout and retry. For example,
timeout-minuteson a GitHub Actions step,timeout_in_minuteswithretry: automaticin Buildkite, ortimeoutwithretryin GitLab CI. -
Or wrap the clone in a timeout yourself. macOS doesn’t include a
timeoutcommand. Install Homebrew’scoreutilsand usegtimeout: - Or clone over HTTPS, so the low-speed settings apply.
Retry the clone
Pair the timeout with a retry, so an aborted clone starts again instead of failing the build:Keep repositories close to your builds
The fastest clone is the one that doesn’t reach the internet.- Seed the repository in your VM image. Clone your largest repositories into the image you build for your Orka VMs. Each job then runs
git fetchfor recent changes instead of a full clone. Push a new version of the image now and then, so the fetches stay small. See Save Orka VM changes to a local or OCI image. - Run a mirror next to your builds. A Git mirror or cache server on the same network as your Orka nodes serves most fetches locally and only goes to your Git host for new commits. For build caching beyond Git, see Bazel remote build execution with Orka.

