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
- Set
fetch-depth: 0on the checkout so all refs are present. - Reference an available ref in the filter (for example
origin/main). - 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/mainHow to prevent it
- Use
fetch-depth: 0for 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
Nx affected empty because of shallow git history in CIFix Nx affected running everything or nothing in CI because the base SHA is missing from a shallow clone - fe…
Nx affected "requires a base and head" in CIFix Nx "affected requires a base and head" in CI - Nx cannot compute affected projects without two git refs t…
Turborepo "No tasks were executed" in CIFix Turborepo "No tasks were executed as part of this run" in CI - the task name or filter matched no package…