Git force push tag when the tag already exists on remote

江枫思渺然 提交于 2020-01-01 03:52:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!