GitHub Actions tj-actions/changed-files "fatal: ambiguous argument"
tj-actions/changed-files diffs the current ref against a base. With the default shallow checkout (fetch-depth: 1), the base commit is not present locally, so git cannot resolve the range and reports an ambiguous argument.
What this error means
A changed-files step fails with git complaining about an ambiguous argument or unknown revision when computing the diff.
github-actions
fatal: ambiguous argument 'origin/main...HEAD': unknown revision or path not in the working tree.
Error: Unable to determine the base and head commits.Common causes
Shallow checkout
fetch-depth: 1 omits the base ref, so the diff range cannot be resolved.
Base ref not fetched
The base branch was never fetched into the local clone.
How to fix it
Fetch enough history
- Set fetch-depth: 0 on actions/checkout so full history is available.
- Keep checkout before the changed-files step.
- Let changed-files resolve the base automatically with full history.
.github/workflows/ci.yml
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: tj-actions/changed-files@v45
id: changedHow to prevent it
- Use fetch-depth: 0 whenever a step diffs against a base ref.
- Order checkout before any diff-based action.
Related guides
GitHub Actions dorny/paths-filter "predicate-quantifier" errorFix dorny/paths-filter predicate-quantifier errors - an invalid value, or list-style filters combined with pr…
GitHub Actions checkout "couldn't find remote ref"Fix actions/checkout "couldn't find remote ref" - the ref input points at a branch, tag, or SHA that does not…
actions/checkout: Inputs & Workflow UsageReference for actions/checkout: clone your repository into the runner, control fetch-depth, submodules, refs,…