fatal: --unshallow on a complete repository does not make sense
ID: cicd/gha-shallow-clone-missing-history
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
GitHub Actions' actions/checkout defaults to fetch-depth: 1 (shallow clone). Git operations requiring history (git log, git describe, semantic-release, changelog generation) fail because commits, tags, or merge bases are missing.
genericWorkarounds
-
95% success Set fetch-depth: 0 in actions/checkout to get full history
- uses: actions/checkout@v4 with: fetch-depth: 0 # Fetches all history for all branches and tags # Required for: git describe, semantic-release, changelog generation -
90% success For PR diff only, fetch the base branch with enough depth
- uses: actions/checkout@v4 with: fetch-depth: 0 - run: git fetch origin ${{ github.base_ref }} # Now git diff origin/${{ github.base_ref }}...HEAD works correctly -
92% success For semantic-release or git describe, also fetch tags
- uses: actions/checkout@v4 with: fetch-depth: 0 fetch-tags: true # Available in actions/checkout@v4+ # Or manually: - run: git fetch --tags origin
Dead Ends
Common approaches that don't work:
-
Running git fetch --unshallow in a step after checkout
55% fail
While this works in some cases, it re-fetches the entire history which is slow for large repos. It also fails if the repo was already fully cloned (error: --unshallow on a complete repository). Use fetch-depth: 0 in checkout instead.
-
Setting fetch-depth to a large fixed number like 100 or 500
60% fail
A fixed depth is a guess that may still be insufficient. If the needed commit (merge base, tag, or blame target) is beyond that depth, the operation still fails. Only fetch-depth: 0 guarantees all history is available.