Git force push tag when the tag already exists on remote

user3606175 picture user3606175 · Sep 12, 2014 · Viewed 41k times · Source

I have a tag already pushed onto the remote. When another user creates the same tag and tries to push, the push will fail because the tag already exists on the remote.

But I thought if I did --f force tag push, it should work. But that is not what I see.

I think I have to do this.

 Create tag
 Push tag -> If push fails -> Delete tag on remote
                           -> push tag again.

Is this correct? Isn`t force pushing a tag supposed to take care of this?

I am using annotated tags with

 git -a v1.0 -f -m "message"

Answer

David Dekanozishvili picture David Dekanozishvili · Sep 24, 2018

This will force push all the tags and overwrite the existing ones.

git push -f --tags