Git force push tag when the tag already exists on remote

前端 未结 3 2070
醉梦人生
醉梦人生 2021-02-05 00:08

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.

Bu

相关标签:
3条回答
  • 2021-02-05 00:44

    Firstly, delete that tag you want to replace in remote:

    git push origin --delete <tag-name>
    

    then push your tag to remote:

    git push --tags
    
    0 讨论(0)
  • 2021-02-05 00:58

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

    git push -f --tags
    
    0 讨论(0)
  • 2021-02-05 00:59

    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.

    0 讨论(0)
提交回复
热议问题