Shallow cloning a git repository can offer some performance improvement, especially for larger projects with a number of commits, by pulling the smallest number of changes possible. This can either be implemented manually using a custom cloning step or by utilizing an Orb.
To fetch and modify the default checkout step, see this article: How do I modify the checkout step?
Some flags to note that can be added to the
git clone <repository> command:
--depth <depth>will limit the number of commits fetched for the repository or branch being checked out.
--shallow-since=<date>will do a shallow checkout from the date specified (date should be formatted as YYYY-MM-DD)
--no-tagsprevents git from cloning any tags from the repository (if the installed version of git supports it).
source & more flags: https://git-scm.com/docs/git-clone
- image: circleci/node:latest
- run: git clone --depth 5 "$CIRCLE_REPOSITORY_URL" --branch "$CIRCLE_BRANCH"