git fetch --unshallow — convert shallow clone to full history
Quick Answer
# Check whether this repository is shallow
git rev-parse --is-shallow-repository
# Convert a shallow clone to full history
git fetch --unshallow
# If you only need more history, not all history
git fetch --depth=100
When this happens
fatal: --shallow-since is only allowed for fetch
# or
warning: Could not find remote branch ...
Your repository was cloned with --depth 1 (common in CI/CD). Commands that need full history, such as git log, git blame, git bisect, or release comparison scripts, may be incomplete until you unshallow the clone.
Other causes & fixes
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.
git fetch --depth=100
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
else
echo "Repository already has full history"
fi
Related