0

I made a spelling error on a tag message I pushed to the origin which I wanted to correct, but I am struggling to work out how to do it.

I edited the annotated tag message on my local branch successfully, using this page: How do I edit an existing tag message in git?

git tag <tag name> <tag name>^{} -f -m "<new message>"

this corrected the tag locally but I couldn't push the tag to the remote:

git push origin <tag name> 

gave me an error

! [rejected]        v1.7 -> v1.7 (already exists)
error: failed to push some refs to 'git@gitlab.com:tompkins/vectri.git'
hint: Updates were rejected because the tag already exists in the remote.

So I tried to simply delete the tag and start again. I deleted it locally and recreated it, but when I tried to use this page How to delete a remote tag? to delete it remotely:

git push --delete origin tagname

I received the error:

remote: GitLab: You cannot delete a tag

is it possible to edit remote tag messages?

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86

1 Answers1

1

I think you have to do:

git push origin -f <tag-name>
eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • that did the trick, I needed to force. thanks. I also noticed that I could log on gitlab and delete the tag with my browser... – ClimateUnboxed Aug 01 '19 at 14:46
  • 2
    Make sure you tell (verbally, perhaps) everyone who picked up the *wrong* tag to *delete their copy* of the wrong tag, too. – torek Aug 01 '19 at 16:47
  • 1
    *Always* be extraordinarily careful when using `git push --force` or `git push -f` on any branch where you are working with other people because it can destroy work and severely annoy your collaborators. Reserve it for times you accidentally push a commit with a password or other sensitive data. – Greg Bacon Aug 01 '19 at 16:59