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

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 on my laptop the tag mytag is shown. I then want to push this to the remote repository so I have this tag on all my clients, so I run git push but I got the message:

Everything up-to-date

And if I go to my desktop and run git pull and then git tag no tags are shown.

I have also tried to do a minor change on a file in the project, then push it to the server. After that I could pull the change from the server to my Desktop computer, but there's still no tag when running git tag on my desktop computer.

How can I push my tag to the remote repository so that all client computers can see it?

This question is related to git git-push git-tag

The answer is


To push a single tag:

git push origin <tag_name>

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

git push --tags

To push specific, one tag do following git push origin tag_name


You can push the tags like this git push --tags


You can push all local tags by simply git push --tags command.

$ git tag                         # see tag lists
$ git push origin <tag-name>      # push a single tag
$ git push --tags                 # push all local tags 

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


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.


How can I push my tag to the remote repository so that all client computers can see it?

Run this to push mytag to your git origin (eg: GitHub or GitLab)

git push origin refs/tags/mytag

It's better to use the full "refspec" as shown above (literally refs/tags/mytag) just in-case mytag is actually v1.0.0 and is ambiguous (eg: because there's a branch also named v1.0.0).


I am using git push <remote-name> tag <tag-name> to ensure that I am pushing a tag. I use it like: git push origin tag v1.0.1. This pattern is based upon the documentation (man git-push):

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

Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to git-push

Fix GitLab error: "you are not allowed to push code to protected branches on this project"? ! [rejected] master -> master (fetch first) Git - What is the difference between push.default "matching" and "simple" error: src refspec master does not match any Issue pushing new code in Github Can't push to GitHub because of large file which I already deleted Changing the Git remote 'push to' default What does '--set-upstream' do? Git push hangs when pushing to Github? fatal: 'origin' does not appear to be a git repository

Examples related to git-tag

What is git tag, How to create tags & How to checkout git remote tag(s) How to git clone a specific tag “tag already exists in the remote" error after recreating the git tag Create a tag in a GitHub repository How do I merge a git tag onto a branch Depend on a branch or tag using a git URL in a package.json? Do Git tags only apply to the current branch? What is the difference between an annotated and unannotated tag? How to create a new branch from a tag? How can I move a tag on a git branch to a different commit?