Skip to content
Latchkey

Bitbucket Pipelines Clone Depth - Shallow Clone Breaks Builds

Bitbucket clones your repo shallowly by default (depth 50). Commands that need older history or tags - versioning, changelogs, git describe, diffing against a base - fail because the commits simply are not in the clone.

What this error means

A build step works on the surface but a git-history-dependent command fails: git describe finds no tag, a diff against an older commit errors, or a tool reports a missing object. Increasing depth makes it pass.

Bitbucket log
fatal: No names found, cannot describe anything.
# or
fatal: Could not parse object 'origin/main~200'.

Common causes

Default depth omits the commit you need

The default clone: depth: 50 fetches only the last 50 commits. A git describe or diff that reaches further back hits commits that are not in the shallow clone.

Tags not fetched

A shallow clone may not include the tag your versioning step needs, so tag-based commands find nothing.

How to fix it

Increase the clone depth

Set a deeper clone: depth globally or per step. Use full only if you truly need all history.

bitbucket-pipelines.yml
clone:
  depth: 200      # or: full

pipelines:
  default:
    - step:
        script: [ git describe --tags ]

Fetch tags explicitly when needed

bitbucket-pipelines.yml
script:
  - git fetch --tags --depth=200
  - git describe --tags

How to prevent it

  • Set clone: depth to cover the history your tooling needs.
  • Fetch tags explicitly in steps that depend on them.
  • Prefer the smallest depth that works to keep clones fast.

Frequently asked questions

What causes "shallow clone"?
The default clone: depth: 50 fetches only the last 50 commits. A git describe or diff that reaches further back hits commits that are not in the shallow clone.
How do I fix shallow clone?
Set a deeper clone: depth globally or per step. Use full only if you truly need all history.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card