To delete a remote Git tag, follow these steps:
Step 1: Delete the Tag Locally
You’ll first need to delete the tag from your local repository. Use the following command:
git tag -d <tagname>
For example, to delete a tag named v1.0.0
:
git tag -d v1.0.0
Step 2: Delete the Tag from the Remote Repository
After deleting the tag locally, you must also delete it from the remote repository. Use the following command:
git push origin --delete <tagname>
For example:
git push origin --delete v1.0.0
This will remove the tag from the remote repository.
Step 3: Verify the Tag Deletion
- Check Local Tags: Run the following command to verify that the tag has been removed locally:
git tag
- Check Remote Tags: Fetch the latest tags from the remote repository to ensure it has been removed:
git fetch --prune origin "+refs/tags/*:refs/tags/*" git tag
Important Notes
- Force Delete Tags: If the tag was force-pushed to the remote repository, you might need to force delete it:
git push --delete --force origin <tagname>
- Tag Names in Use: If another developer or process recreates the tag after deletion, you may need to coordinate to avoid issues.