Search code examples
gitgitlabgit-tag

GIT returning fatal "[tag] already exists" error when Deleting then Recreating Tags


In GIT, I am trying to execute a series of GIT commands to delete an existing tag then recreate it. However, it is returning a "fatal: tag '2.0.1' already exists" error. Anyone have any idea what I'm doing wrong or what command I'm possibly missing?

I am executing the following sequence of commands:

git clone git@git.someaddress.com/test_project project_dir
cd project_dir
git push --delete origin 2.0.1
git tag 2.0.1 -m "Recreated tag"

Currently to work around this, after I execute the push --delete command, I'm deleting project_dir and recloning the repo to create the tag, which isn't very efficient.


Solution

  • You also have to delete your local copy of the tag:

    git tag -d 2.0.1
    

    Deleting it from the remote does not delete it from your local repository.