> ## Content Index
> Fetch the complete content index at: https://ivans.io/llms.txt
> Use this file to discover other available public pages before exploring further.

# Speeding up git operations for CI/CD
- URL: https://ivans.io/speeding-up-git-operations-for-ci-cd/
- Published: 2022-03-17T21:21:19.000Z
- Updated: 2022-04-20T19:11:18.000Z
- Author: Ivan Smirnov
- Tags: Import 2022-12-02 03:12, #Import 2026-08-12 21:23

I recently found myself undergoing an epic journey to speed up our CICD builds at work. After some initial digging, I found that our git clone operations were taking 3 minutes and pulling 2gb of data, just to test a tiny Golang binary (3,500 LoC, 20mb).

With some easy tweaks, I was able to reduce our clone time to 5 seconds and only pull 35mb of data.

## Faster Git clones

*\*Requires a modern version of git (v2.25+) with sparse-checkout support.*

```
# clone our repo. Note the blob filter and --no-checkout
git clone --no-checkout --filter=blob:none ssh://git@example.com:22/monorepo.git

# Pop into the folder. If you ls, there is only the .git/ foldere
cd monorepo

## Set up our sparse checkout
git sparse-checkout init --cone

# Specify the paths we care about 
git sparse-checkout set /your_path/ /some/other/path

# Pull the files.
git read-tree -mu HEAD

```

## Additional links

I found these three links very helpful in my research:

- [https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/](https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/?ref=ivans.io)
- [https://dev.to/patricksevat/optimize-your-git-clone-fetch-strategy-for-ci-pipeline-3pka](https://dev.to/patricksevat/optimize-your-git-clone-fetch-strategy-for-ci-pipeline-3pka?ref=ivans.io)
- [https://stackoverflow.com/questions/9572407/git-sparse-checkout-with-exclusion](https://stackoverflow.com/questions/9572407/git-sparse-checkout-with-exclusion?ref=ivans.io)