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.
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.
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 [email protected]: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 2The --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.
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server
fatal: unable to access: Proxy auto-configuration failed
How to fix 'Proxy auto-configuration failed' in Git