Skip to content
Latchkey

Turborepo --filter affected needs a base ref (full history) in CI

A filter like --filter="...[origin/main]" tells turbo to select packages changed since a git ref. In CI the shallow default clone often lacks that ref, so turbo cannot diff and either errors or selects nothing.

What this error means

turbo with --filter="...[ref]" selects no packages, or fails resolving the base ref, because the comparison commit is not in the fetched history.

Turborepo
x could not resolve git ref "origin/main"
  ensure the ref is available (fetch-depth: 0)

Common causes

The base ref is not in the shallow clone

With the default fetch-depth: 1, the ref you diff against is not present locally, so turbo cannot compute changed packages.

The base branch was not fetched

Even with more depth, if origin/main was never fetched, turbo has no base to compare against.

How to fix it

Fetch full history for affected filtering

  1. Set fetch-depth: 0 on the checkout so all refs are present.
  2. Reference an available ref in the filter (for example origin/main).
  3. Re-run so turbo can diff against the base.
.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0
- run: npx turbo run build --filter="...[origin/main]"

Confirm the ref resolves

Print the ref before running turbo so you can confirm the base commit exists locally.

Terminal
git rev-parse origin/main

How to prevent it

  • Use fetch-depth: 0 for any turbo affected filter.
  • Reference a ref that CI actually fetches.
  • Treat "no packages selected" as a missing-base signal, not a real no-op.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →