问题
I have a tag already pushed onto the remote, and when another user creates the same tag and tries to push, push will fail because tag already exists on the remote.
But I thought if I do --f force tag push, it should be 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? Isnt force push tag supposed to take care of this?
I am using annotated tags with
git -a v1.0 -f -m "message"
回答1:
In my case, remote was rejecting an force push when the tag already exists.
So, when the push was rejected, I did
git push --delete origin tagname
and pushed the new tag.
Please see Torek's comment to my question. There is a case when remote can reject the delete too.
回答2:
This will force push all the tags and overwrite the existing ones.
git push -f --tags
回答3:
Firstly, delete all the tags in remote:
git tag -l | awk 'BEGIN{ORS=" "}{print $0}' | xargs git push origin --delete
then push all tags to remote:
git push --tags
来源:https://stackoverflow.com/questions/25815631/git-force-push-tag-when-the-tag-already-exists-on-remote