How to fix fatal: Server does not support --shallow-exclude in Git
This error occurs when attempting to use git clone --shallow-exclude with a remote server that doesn't support this advanced shallow cloning feature. The server may be running an older Git version or have protocol limitations.
Quick fix
Fixes fatal: Server does not support --shallow-exclude
git clone --depth 1 https://github.com/user/repo.git- Use --depth instead of --shallow-exclude
- Try --shallow-since as an alternative
- Switch from HTTPS to SSH protocol
- Verify you're using ref names, not commit hashes
git clone --depth 1 https://github.com/user/repo.gitfatal: Server does not support --shallow-exclude
What this error means
The --shallow-exclude option allows you to create a shallow clone while excluding commits reachable from specific remote branches or tags. This is an advanced feature that requires the remote Git server to support the "deepen-not" capability through Git protocol v2. When you see this error, it means the remote repository's Git server either doesn't advertise the shallow-exclude capability, is running an older version of Git (pre-2.18), or is using a transport protocol (like dumb HTTP) that doesn't support advanced shallow features. This typically happens when cloning from older self-hosted Git servers, certain cloud providers with legacy Git infrastructure, or when using HTTPS with repositories that haven't enabled protocol v2 support.
Typical symptoms
- Command fails immediately with "fatal: Server does not support --shallow-exclude"
- Error occurs during git clone with --shallow-exclude flag
- May also see "the remote end hung up unexpectedly" with some servers
- Works with --depth but fails with --shallow-exclude on the same repository
- SSH clones may succeed where HTTPS clones fail with this option
Common causes
- Remote Git server is running a version older than 2.18 (released June 2018)
- Server hasn't enabled Git protocol v2 support in its configuration
- Using dumb HTTP transport which doesn't support shallow capabilities
- Server-side Git installation lacks the "deepen-not" capability
- Attempting to use commit hashes instead of branch/tag names with --shallow-exclude
- Repository host (GitHub, GitLab, etc.) hasn't implemented this feature yet
How to fix "fatal: Server does not support --shallow-exclude"
The most straightforward workaround is to use the more widely supported --depth option for shallow cloning:
git clone --depth 1 https://github.com/user/repo.gitThis creates a shallow clone with only the most recent commit. Adjust the depth number as needed (e.g., --depth 50 for the last 50 commits).
If you need to exclude older history, use --shallow-since instead, which is more widely supported:
git clone --shallow-since="2024-01-01" https://github.com/user/repo.gitThis clones commits only from the specified date forward, which can achieve similar results to --shallow-exclude.
Some servers support shallow-exclude over SSH but not HTTPS. Try cloning with SSH instead:
git clone --shallow-exclude=old-branch git@github.com:user/repo.gitMake sure you have SSH keys configured for the remote server.
The --shallow-exclude option requires branch or tag names, not arbitrary commit SHAs:
# Correct - using branch name
git clone --shallow-exclude=development https://github.com/user/repo.git
# Incorrect - using commit hash
git clone --shallow-exclude=abc123def https://github.com/user/repo.gitIf you were using a commit hash, switch to the branch or tag name instead.
If you don't strictly need a shallow clone, do a regular full clone:
git clone https://github.com/user/repo.gitYou can later convert to a shallow repository or clean up old history if disk space is a concern.
If you control the remote server, verify the Git version and upgrade if needed:
# On the server
git --version
# Should be 2.18 or later for protocol v2 supportEnsure the server has protocol.version configured:
git config --global protocol.version 2Advanced notes
The --shallow-exclude feature was introduced as part of Git's protocol v2 capabilities, specifically the "deepen-not" command. This requires both client and server to be running Git 2.18 or later (released June 2018).
For self-hosted Git servers, enabling protocol v2 may require additional configuration beyond just upgrading Git. On GitLab, for example, you need to ensure the Git-Protocol HTTP header is properly propagated through workhorse to gitaly. For SSH, the sshd server must be configured to accept the GIT_PROTOCOL environment variable.
The --shallow-exclude option can be used multiple times to exclude several branches. Internally, it's equivalent to running "git rev-list --not <ref>" on the server side. Note that --shallow-exclude cannot be used together with --depth, but can be combined with --shallow-since.
If you're working with a repository that doesn't support --shallow-exclude, consider whether you actually need this specific feature. In many CI/CD scenarios, --depth 1 provides sufficient history reduction. For development workflows where you need selective history, a full clone followed by local branch management may be more reliable than relying on advanced shallow features that aren't universally supported.
Frequently asked questions
- What does "fatal: Server does not support --shallow-exclude" mean?
- The --shallow-exclude option allows you to create a shallow clone while excluding commits reachable from specific remote branches or tags. This is an advanced feature that requires the remote Git server to support the "deepen-not" capability through Git protocol v2. 18), or is using a transport protocol (like dumb HTTP) that doesn't support advanced shallow features.
- How do I fix "fatal: Server does not support --shallow-exclude"?
- This error occurs when attempting to use git clone --shallow-exclude with a remote server that doesn't support this advanced shallow cloning feature. The server may be running an older Git version or have protocol limitations.
- What causes "fatal: Server does not support --shallow-exclude"?
- Remote Git server is running a version older than 2.18 (released June 2018) Server hasn't enabled Git protocol v2 support in its configuration Using dumb HTTP transport which doesn't support shallow capabilities
- Is the "fatal: Server does not support --shallow-exclude" error serious?
- It is a low-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Git Official Documentation
- ๐Docs: git clone shallow options(Official Docs)