git fetch --unshallow — convert shallow clone to full history

# Check whether this repository is shallow
git rev-parse --is-shallow-repository

# Convert the current clone to full history
git fetch --unshallow origin

# If you need only a bounded amount of additional history
git fetch --deepen=100
fatal: --unshallow on a complete repository does not make sense
# or a history-dependent command cannot see older commits

A shallow clone stores only part of the commit graph. Commands such as git log, git blame, git bisect, and release comparison scripts can therefore stop at the shallow boundary.

A shallow clone has an explicit history boundary

Git marks a shallow repository with a boundary in .git/shallow. A clone created with --depth 1 can check out the current snapshot, but it does not have the parent commits needed for operations that traverse history.

The problem is repository history, not a damaged working tree. Confirm the state before fetching so a script does not treat an already complete repository as an error.

git rev-parse --is-shallow-repository
git log --oneline --decorate -n 5
git remote -v

Use git fetch --unshallow for the full commit graph

Run git fetch --unshallow when commands need every reachable commit from the configured remote. Specify the remote explicitly when the repository has more than one remote or does not use origin.

git fetch --unshallow origin

# Confirm that the boundary is gone
git rev-parse --is-shallow-repository
# false

Deepen the clone when full history is unnecessary

Use --deepen to add a fixed number of commits to the existing depth. Use --depth when you want to set the total depth. Neither option is a substitute for full history when a tool must inspect all ancestors.

# Add 100 commits to the current depth
git fetch --deepen=100 origin

# Set the total depth to 100 commits
git fetch --depth=100 origin

Request full history at checkout time

If the shallow clone is created by CI, changing the checkout configuration is more reliable than fetching extra history in every job. For GitHub Actions, set fetch-depth: 0 on the checkout step when the workflow needs tags or the complete history.

- uses: actions/checkout@v4
  with:
    fetch-depth: 0

Check if your clone is shallow

Before running git fetch --unshallow, confirm that Git still considers the repository shallow. A full clone prints false and does not need unshallowing.

git rev-parse --is-shallow-repository    # prints "true" if shallow

Convert shallow clone to full history

This is the direct fix when you need the complete commit history. It downloads the missing commits from the configured remote.

git fetch --unshallow

# If your remote is not named origin, specify it:
git fetch --unshallow origin

Fetch only more depth, not full history

If you only need more commits for a build or comparison, increasing depth is faster than downloading the entire repository history. Use --deepen to add commits to the existing boundary or --depth to set the final total depth.

git fetch --deepen=100 origin

# Set the total history depth to 100
git fetch --depth=100 origin

If git fetch --unshallow says the repository is complete

The message "fatal: --unshallow on a complete repository does not make sense" means the clone is already full history. Use the shallow check first when writing scripts.

if git rev-parse --is-shallow-repository | grep -q true; then
  git fetch --unshallow origin
else
  echo "Repository already has full history"
fi