Skip to content
Latchkey

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

  1. Set fetch-depth: 0 on actions/checkout so full history is available.
  2. Keep checkout before the changed-files step.
  3. 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: changed

How to prevent it

  • Use fetch-depth: 0 whenever a step diffs against a base ref.
  • Order checkout before any diff-based action.

Related guides

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