Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 543
Jonas Avatar asked Mar 04 '11 15:03

Jonas


People also ask

Which command is used to push a tag into remote repository?

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

Do I need to push git tag?

Git Push Tag Push Tag to Remote: The git tag command creates a local tag with the current state of the branch. When pushing to a remote repository, tags are NOT included by default. It is required to explicitly define that the tags should be pushed to remote.

Are tags pushed with git push?

Sharing tags is similar to pushing branches. By default, git push will not push tags. Tags have to be explicitly passed to git push .


2 Answers

To push a single tag:

git push origin <tag_name> 

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

# not recommended git push --tags 
like image 155
Trevor Avatar answered Sep 22 '22 02:09

Trevor


git push --follow-tags

This is a sane option introduced in Git 1.8.3:

git push --follow-tags 

It pushes both commits and only tags that are both:

  • annotated
  • reachable (an ancestor) from the pushed commits

This is sane because:

  • you should only push annotated tags to the remote, and keep lightweight tags for local development to avoid tag clashes. See also: What is the difference between an annotated and unannotated tag?
  • it won't push annotated tags on unrelated branches

It is for those reasons that --tags should be avoided.

Git 2.4 has added the push.followTags option to turn that flag on by default which you can set with:

git config --global push.followTags true 

or by adding followTags = true to the [push] section of your ~/.gitconfig file.