Lesstep
GitLab · CI/CD jobs · Checked November 22, 2026

GitLab CI: "fatal: reference is not a tree"

A public GitLab issue reports this message when a job clones with a depth of 1 and new commits are pushed: the job then cannot check out its commit because it is not in the shallow fetch. Current GitLab documentation says a job fetches the commit of its pipeline by its SHA, so the commit of the pipeline itself is found at any depth. For any other commit a job needs, the documentation shows fetching it with git fetch --depth=1 (GitLab: issue 32636 and configure runners, shallow cloning, checked November 22, 2026).

Checking out e12a355c as master...
fatal: reference is not a tree: e12a355c0fbeaa6b5695eb925fa29bb2ba3ff82e

What the issue shows

The two lines above are from the log in the GitLab issue titled "package-and-qa can fail when new commits are pushed since it fetches Git repo with a depth of 1", where the second line appears once for each of three attempts. The issue states the cause as the depth of 1 together with new commits pushed in the meantime, and suggests fetching with the default depth of 20. The issue describes one project, so it does not cover every case of the message.

To see why a job failed, right next to the job: Pipelines and Jobs Inbox for GitLab CI, a plugin for JetBrains IDEs, shows next to a failed job its status, how long it ran and the message GitLab gives for the failure, and opens the job's log in a console viewer at the bottom of the IDE.

What the documentation says now

Fetch one older commit

This is the example of the documentation for a job that needs one older commit. The job keeps GIT_DEPTH at 1 and fetches the base commit of the merge request by its SHA before it compares.

list-changed-files:
  variables:
    GIT_DEPTH: "1"
  script:
    - BASE_SHA="${CI_MERGE_REQUEST_TARGET_BRANCH_SHA:-$CI_MERGE_REQUEST_DIFF_BASE_SHA}"
    - git fetch --depth=1 origin "$BASE_SHA"
    - git diff --name-only "$BASE_SHA" HEAD
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

To keep the whole history instead, set it for one job or for all jobs:

variables:
  GIT_DEPTH: "0"

The project setting for the depth is described in the documentation on limiting the number of changes fetched during clone. The configure runners page says GIT_DEPTH can be set globally or per job in the variables section.

GitLab jobs in IntelliJ IDEA

Pipelines and Jobs Inbox for GitLab CI, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the pipelines of your GitLab projects with their jobs by stage. Next to a failed job it shows the status, how long the job ran and the message GitLab gives for the failure, such as the ones above (GitLab gives none for a script that failed), and it opens the log of a job in a console viewer at the bottom of the IDE. Reading is free; retrying, cancelling and running are Pro (US$1.50 a month, with a 30-day trial).

Get it on JetBrains Marketplace

GITLAB is a trademark of GitLab Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by GitLab Inc. or JetBrains.

More: GitLab "Getting source from Git repository" HTTP/2 error · GitLab job dropped as stuck or over its timeout · GitLab "not allowed to download code" · GitLab "ERROR: Job failed: exit code 137" · GitLab job log refused or empty · GitLab failed to pull image · GitLab pipeline or job refused (400, 403, 409, 429) · GitLab pipeline plugins for IntelliJ IDEA, compared · 日本語