Decrease repository clone time in CI / CD

When using CI / CD to sync to repository from dev to build repository, sometime the build repo size is huge.

First step is to reduce build repo size, If it doesn’t contain useful history you can clean up commits in it. GitLab has an article about how to do so.

But if you just want to make clone repo faster with large history, you can clone single branch with top 1 level of history using the following:

git clone {Git URL} --depth 1 --branch main --single-branch /tmp/temprepo

You can also add commit on top of such repo and push it. (CD)

This works great when you want to clone a remote repository of a hosting provider and push for auto deployments.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *