How do you push a tag to a remote repository using Git?

前端 未结 9 862
滥情空心
滥情空心 2020-11-22 16:31

I have cloned a remote Git repository to my laptop, then I wanted to add a tag so I ran

git tag mytag master

When I run git tag

相关标签:
9条回答
  • 2020-11-22 17:25

    To expand on Trevor's answer, you can push a single tag or all of your tags at once.

    Push a Single Tag

    git push <remote> <tag>
    

    This is a summary of the relevant documentation that explains this (some command options omitted for brevity):

    git push [[<repository> [<refspec>…]]
    
    <refspec>...
    

    The format of a <refspec> parameter is…the source ref <src>, followed by a colon :, followed by the destination ref <dst>

    The <dst> tells which ref on the remote side is updated with this push…If :<dst> is omitted, the same ref as <src> will be updated…

    tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>.

    Push All of Your Tags at Once

    git push --tags <remote>
    # Or
    git push <remote> --tags
    

    Here is a summary of the relevant documentation (some command options omitted for brevity):

    git push [--all | --mirror | --tags] [<repository> [<refspec>…]]
    
    --tags
    

    All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line.

    0 讨论(0)
  • 2020-11-22 17:26

    To push a single tag:

    git push origin <tag_name>
    

    And the following command should push all tags (not recommended):

    git push --tags
    
    0 讨论(0)
  • 2020-11-22 17:33

    Tags are not sent to the remote repository by the git push command. We need to explicitly send these tags to the remote server by using the following command:

    git push origin <tagname>
    

    We can push all the tags at once by using the below command:

    git push origin --tags
    

    Here are some resources for complete details on git tagging:

    http://www.cubearticle.com/articles/more/git/git-tag

    http://wptheming.com/2011/04/add-remove-github-tags

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