Chromatic shallow clone: baseline / ancestor not found in CI
Chromatic uses git history to find the baseline build to compare against. The default CI checkout is shallow (depth 1), so Chromatic cannot walk back to the ancestor commit and either treats everything as new or fails baseline detection.
What this error means
Chromatic reports "Failed to find ancestor build" or captures every story as new on a normal PR. Warnings mention a shallow clone or missing git history.
! Unable to find baseline. This may be because the git history is shallow.
Run `git fetch --unshallow` or set fetch-depth: 0 in your checkout.Common causes
Shallow checkout hides the ancestor commit
CI checks out with fetch-depth: 1 by default. Chromatic needs earlier commits to locate the baseline build and cannot with only one commit.
The base branch history is not fetched
Even with some depth, if the base branch commit is not present, Chromatic cannot resolve the baseline.
How to fix it
Fetch full history in the checkout
Set fetch-depth: 0 so Chromatic can walk git history to the baseline.
- uses: actions/checkout@v4
with:
fetch-depth: 0Unshallow if depth cannot be changed
When you cannot change the checkout, unshallow the repo before running Chromatic.
git fetch --unshallow || true
npx chromatic --project-token=$CHROMATIC_PROJECT_TOKENHow to prevent it
- Use
fetch-depth: 0for jobs that run Chromatic. - Ensure the base branch commit is present in the checkout.
- Avoid squashing away the ancestor Chromatic relies on.