Git tag deletion errors occur when the tag doesn't exist, when a branch has the same name, or when server-side protections prevent deletion. Solutions depend on whether you're deleting local or remote tags.
Git tags are references to specific commits, commonly used to mark release versions (v1.0.0, v2.1.3). When you try to delete a tag, Git needs to locate it either locally or on a remote repository. Errors occur when Git cannot find the tag, when there's ambiguity with branch names, or when the remote server blocks the deletion. Deleting a local tag uses `git tag -d <tagname>`, while deleting a remote tag requires pushing the deletion with `git push --delete origin <tagname>` or the older refspec syntax `git push origin :refs/tags/<tagname>`. Each method can fail for different reasons. Common scenarios include: the tag only exists remotely (not locally), the tag is protected on GitLab/GitHub, the tag name matches a branch name causing ambiguity, or the tag was already deleted but your local view is stale. Understanding which type of tag you're dealing with is key to resolving the error.
Before deleting, confirm the tag exists and check its exact spelling:
# List local tags
git tag
# List remote tags
git ls-remote --tags origin
# Search for a specific pattern
git tag -l "v1.*"Tag names are case-sensitive. A tag named V1.0 is different from v1.0.
To delete a tag from your local repository:
git tag -d <tagname>Example:
git tag -d v1.0.0If you get "tag not found", the tag may only exist on the remote. Fetch it first:
git fetch --tags
git tag -d v1.0.0To delete a tag from the remote repository:
git push --delete origin <tagname>Example:
git push --delete origin v1.0.0If this fails with an ambiguity error (tag name matches a branch), use the explicit refs syntax:
git push origin :refs/tags/v1.0.0This explicitly specifies you're deleting a tag, not a branch.
When a tag and branch have the same name, Git cannot determine which one to delete:
error: dst refspec v1.0.0 matches more than oneSolution: Use the full refs path to specify the tag explicitly:
# Delete the tag (not the branch)
git push origin :refs/tags/v1.0.0
# Or delete both if needed
git push origin :refs/tags/v1.0.0 :refs/heads/v1.0.0If you see "pre-receive hook declined" or "You don't have permission", the tag may be protected.
For GitLab:
1. Go to Settings > Repository > Protected tags
2. Find and unprotect the tag, or
3. Delete via GitLab UI: Repository > Tags > Delete button (requires Maintainer role)
For GitHub:
1. Go to Settings > Branches (note: GitHub protects tags through branch rules for matching refs)
2. Check tag protection rules
3. Delete via GitHub UI: Releases > Delete the associated release and tag
Protected tags are intentional security features to prevent accidental deletion of release tags.
If tags were deleted on the remote but still appear locally, prune stale tags:
# Fetch and prune tags not on remote
git fetch --prune --prune-tags
# Or configure automatic pruning
git config fetch.pruneTags trueTo manually remove all local tags and re-fetch from remote:
git tag -l | xargs git tag -d
git fetch --tagsTo delete several tags in one command:
# Delete multiple local tags
git tag -d tag1 tag2 tag3
# Delete multiple remote tags
git push --delete origin tag1 tag2 tag3To delete all tags matching a pattern:
# Delete all local v1.x tags
git tag -l "v1.*" | xargs git tag -d
# Delete all matching remote tags
git tag -l "v1.*" | xargs -I {} git push --delete origin {}If git ls-remote shows the tag but deletion fails with "non-existent ref", your fetch and push URLs may differ:
git remote -vIf they point to different servers, fix the configuration:
# Set both URLs to the same location
git remote set-url origin https://github.com/user/repo.git
git remote set-url --push origin https://github.com/user/repo.git### Lightweight vs Annotated Tags
Git has two types of tags:
- Lightweight tags: Simple pointers to commits (like bookmarks)
- Annotated tags: Full objects with author, date, and message
Both are deleted the same way, but annotated tags are more common for releases. Check tag type with:
git cat-file -t <tagname>
# Returns "commit" for lightweight, "tag" for annotated### Recovering a Deleted Tag
If you accidentally delete a tag and know the commit it pointed to:
# Find the commit SHA from reflog or logs
git reflog
# Recreate the tag
git tag v1.0.0 <commit-sha>
git push origin v1.0.0### Git Bug in Version 2.11.0
There was a known bug in Git 2.11.0 (common on Ubuntu 14.04) where tag deletion would fail incorrectly. Upgrading Git resolves this issue:
# Check Git version
git --version
# Upgrade on Ubuntu
sudo add-apt-repository ppa:git-core/ppa
sudo apt update && sudo apt install git### CI/CD Considerations
In CI/CD pipelines, tag deletion may fail due to:
- Shallow clones (--depth 1) not fetching tags
- Limited permissions in the CI environment
- Protected tag rules blocking automated deletion
Ensure your CI runner has appropriate permissions and uses --tags when fetching.
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
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