Shallow Repository Cloning

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-tags prevents 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

version: 2.1

jobs:
build:
docker:
- image: circleci/node:latest
steps:
- run: git clone --depth 5 "$CIRCLE_REPOSITORY_URL" --branch "$CIRCLE_BRANCH"
Was this article helpful?
0 out of 2 found this helpful

Comments

0 comments

Article is closed for comments.