Lesstep
Bitbucket Cloud · Pipelines · Checked November 2, 2026

Bitbucket Pipelines: Git commands that fail in a shallow clone

At the start of each step, Pipelines clones your repository. For a branch or a tag, that clone has only the last 50 commits of that one branch (Atlassian's Git clone behavior). A command in your script that needs another branch, older history or an older tag stops with one of these. We made a clone the same way with Git 2.53 and got:

fatal: ambiguous argument 'origin/main': unknown revision or path not in the working tree.
fatal: No names found, cannot describe anything.
fatal: origin/main...HEAD: no merge base
 ! [remote rejected] HEAD -> x (shallow update not allowed)

How each kind of build clones

Atlassian's article on a slow build setup, Bitbucket Pipelines build setup is running longer than expected, gives a sample clone command for each kind of build:

A clone with --depth takes only the branch it names. In ours, git branch -a listed that branch alone, and remote.origin.fetch was +refs/heads/feature:refs/remotes/origin/feature. The clone without a depth had every branch.

origin/main is missing

In a build of a feature branch, origin/main does not exist. git fetch origin main does not add it either: with that narrow fetch setting, it only fills FETCH_HEAD. Name where it should go:

script:
  - git fetch origin "+refs/heads/main:refs/remotes/origin/main"
  - git diff --name-only origin/main...HEAD

The step needs no credentials for this. Pipelines points Git at its own proxy on localhost:29418 so a step can reach its repository, as Atlassian's article on "Failed to connect to localhost port 29418" shows.

When the two branches split further back than the clone reaches, the three-dot diff stops with "no merge base". Fetch the full history together with main:

  - git fetch --unshallow origin "+refs/heads/main:refs/remotes/origin/main"

In a pull-request build, the destination branch is already there, named in $BITBUCKET_PR_DESTINATION_BRANCH.

git describe and older tags

The clone brings the tags that point at its 50 commits. When the last tag is older, git describe finds none. Fetching the tags alone does not help: in our test the tag arrived, but the history between it and the build's commit was still cut off, and Git answered fatal: No tags can describe '…'. Fetch the history and the tags together:

  - git fetch --unshallow --tags origin
  - git describe --tags

An Atlassian Community thread from 2019, "Shallow clone for pipelines is removing version tags", reports the same: the tag list was empty once more than 50 commits had passed since the last version tag.

Pushing to another Git host

Atlassian's article Pushing to a remote git repository from a Bitbucket Pipeline build fails with error "shallow update not allowed" (updated September 26, 2025): some Git hosts, and hosting services that deploy on git push, refuse a push from a shallow clone with (shallow update not allowed) or (unpacker error). A new bare repository refused ours the same way. The article's fix is a full clone.

depth: full on the step that needs it

pipelines:
  default:
    - step:
        clone:
          depth: full
        script:
          - git describe --tags

Set on one step, the other steps keep the faster clone. Under clone: at the top of the file, it applies to every step. SonarQube's page for Bitbucket Pipelines asks for the full depth too, so the scanner has all of the history.

Depth also matters when you re-run an old build. A build more than 50 commits behind its branch fails with "The commit could not be found in the cloned repository. This can be caused by using force push or not having a deep enough clone" (Atlassian's article, and "We couldn't clone the repository").

Bitbucket Pipelines in IntelliJ IDEA

Pipeline Inbox for Bitbucket Pipelines, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the pipelines of all your Bitbucket Cloud repositories in an IDE tool window, with their steps, the failed step and the command it stopped at, and the step's log as Bitbucket writes it. The list, steps and logs are free; running, re-running and stopping pipelines are Pro (US$1.50 a month, with a 30-day trial).

Get it on JetBrains Marketplace

Atlassian, Bitbucket and Bitbucket Pipelines are trademarks of Atlassian; SonarQube is a trademark of SonarSource SA; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Atlassian, SonarSource or JetBrains.

More: The scheduled pipeline did not run · "Container 'build' failed to pull image" · "Connection refused" to a service (MySQL, PostgreSQL, Redis) · "Not authorized to perform sts:AssumeRoleWithWebIdentity" (OIDC to AWS) · Test results not showing · A variable is empty · "Host key verification failed" (SSH) · "Cannot connect to the Docker daemon" · "authorization denied by plugin pipelines" (Docker) · "Container 'docker' exceeded memory limit." · Pipelines did not run after a push · "Container 'Build' exceeded memory limit." · "Exceeded build time limit of 120 minutes" · The cache is not used · "unexpected system error" · "command not found" · Submodules not cloned · "We couldn't clone the repository" · "No online runner available" · "No space left on device" · "Step exceeded processing limits" · The artifact is missing in the next step · The build passed before and fails now · Build setup takes too long · "You've run out of build minutes" · "Permission denied to update branch" · "You have reached your pull rate limit" (Docker Hub) · "There is an error in your bitbucket-pipelines.yml" · "This pipeline was paused" (deployments) · Git LFS files that arrive as pointers, and LFS pushes from a step · A step skipped by condition: changesets (includePaths) · Bitbucket Pipelines plugins for IntelliJ IDEA, compared · 日本語