How to only push a specific tag to remote?

Git

Git Problem Overview


Is there a command like git push --tag tag_a? I only found git push --tags.

Git Solutions


Solution 1 - Git

You can simply use:

git push origin tag_a

Alternatively (mainly to solve tag/branch name clashes), you could use:

git push origin refs/tags/tag_a

Solution 2 - Git

As pointed out by Pavel Šimerda, you can simply do

git push <remote> <tag>

I've added the specification for a remote <remote> so that the command doesn't depend on a user's push.default configuration.

Here is a summary of the relevant documentation that explains how to push a specific tag:

> git push [ […]] > > ... > 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>.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYad SmoodView Question on Stackoverflow
Solution 1 - GitPavel ŠimerdaView Answer on Stackoverflow
Solution 2 - Gituser456814View Answer on Stackoverflow