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 errorCommon 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
- Set fetch-depth: 0 on actions/checkout so the base branch is available.
- Set DEFAULT_BRANCH to the repo default if it differs from main.
- 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: mainHow 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
actions/dependency-review-action "only runs on pull_request events"Fix actions/dependency-review-action failing because it was triggered on a non-pull_request event.
reviewdog reports no findings but the step exits 1Fix reviewdog failing the job with exit 1 despite reporting no findings, caused by reporter/level/fail-level…
wagoid/commitlint-github-action "subject may not be empty"Fix wagoid/commitlint-github-action "subject may not be empty" caused by commit messages that violate Convent…