Removing a tag when having a branch with the same name

Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This article provides instructions on how to securely delete a tag from remote when the tag to be removed has the same name as a branch in the repository.

Environment

This is for any git repository.

Solution

Since git uses different namespaces for tag and branches, you can have a tag with the same name as a branch in your repository. However, depending on what command is used to delete a tag from remote, you might accidentally delete the branch with the same name.

To securely delete a tag from remote, you can specify the full ref in the command, which will make sure it never accidentally deletes a branch : 

1 git push origin :refs/tags/<TAG_NAME>

Replace the <TAG_NAME> field with the name of the tag to be removed. This command needs to be executed inside your local clone of the repository.

Updated on February 25, 2025

Still need help?

The Atlassian Community is here for you.