Skip to content
Latchkey

github/super-linter "fatal: ref does not exist" (default branch not fetched)

super-linter diffs changed files against the default branch. A shallow checkout (fetch-depth: 1) leaves the base ref absent, so the diff command fails.

What this error means

super-linter errors with "fatal: ambiguous argument" or "ref does not exist" when computing changed files.

github-actions
fatal: ambiguous argument 'main...HEAD': unknown revision or path not in the working tree
##[error]Linter exited with error

Common causes

Shallow checkout

Default fetch-depth: 1 does not bring the default branch commit needed for the diff.

DEFAULT_BRANCH misconfigured

The configured default branch name does not match the repo, so the ref is absent.

How to fix it

Checkout with full history

  1. Set fetch-depth: 0 on actions/checkout so the base branch is available.
  2. Set DEFAULT_BRANCH to the repo default if it differs from main.
  3. Re-run the linter.
.github/workflows/lint.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0
- uses: super-linter/super-linter@v7
  env:
    DEFAULT_BRANCH: main

How to prevent it

  • Use fetch-depth: 0 for any action that diffs against the base branch.
  • Keep DEFAULT_BRANCH aligned with the repository default.

Related guides

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