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.
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.
clone:
depth: 200 # or: full
pipelines:
default:
- step:
script: [ git describe --tags ]Fetch tags explicitly when needed
script:
- git fetch --tags --depth=200
- git describe --tagsHow to prevent it
- Set
clone: depthto 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.