# Delete a tag

Remove a tag from a repository; the commit it named stays.

Deleting a tag here is the same act as `git push --delete origin v1.0.0`, and it passes the same
checks a push does. The commit the tag named stays in the repository; only the tag goes. Anything
that already fetched the tag keeps its own copy. Tags are created by pushing them or by publishing a
release (see [Publish a release](publish-a-release.md)). Replace v1.0.0 with the tag's name
and `5d6c2a1e-7b3f-4c8d-9e0a-1b2c3d4e5f60` with the repository's id.

## Prerequisites

- Permission for `git:PushRepository` on the repository, the same permission a push needs.
- In the Deutsche Cloud Console, also `git:GetRepository` to open the repository's tags (without it the page
  is not found).
- For a tag matching a tag protection rule, also `git:PushProtectedTag` (see
  [Protect tags](protect-tags.md)).
- The repository is not archived, not a mirror and not still importing: those are read-only, and
  the delete is refused with the reason.

## Delete it

**Console**
1. Open the repository. On the **Code** tab, choose **Tags** (shown with the number of tags).
2. On the tag's row, choose the bin icon (**Delete tag v1.0.0**).
3. In the **Delete tag** dialog, choose **Delete tag**. The tag disappears from the list.

If you lack `git:PushRepository` or the repository is read-only, the page says why above the list
and the bin icon does nothing.

**CLI**
```sh
dcloud git tags delete 5d6c2a1e-7b3f-4c8d-9e0a-1b2c3d4e5f60 v1.0.0
```

**API**
```http
DELETE /git/api/repositories/5d6c2a1e-7b3f-4c8d-9e0a-1b2c3d4e5f60/tags/v1.0.0
```

A tag name containing slashes is URL-encoded segment by segment (`release/v1` stays
`release/v1`, each part encoded on its own).

## Result

The call answers `{ "success": true, "data": { "name": "v1.0.0" } }`, and the tag is no longer
listed under **Tags**. The commit it named is still in the history. A delete that cannot happen
answers `409` with the reason, for example `Tag "v1.0.0" does not exist.`, or, for a protected tag,
`tag "v1.0.0" is protected (rule "v*"): you may not delete it. Protected tags need
git:PushProtectedTag.` Without `git:PushRepository` the answer is `403`.

## Related

- [Protect tags](protect-tags.md)
- [Publish a release](publish-a-release.md)
- `git.tags.delete` · `dcloud git tags delete`
