Is there a command like git push --tag tag_a
? I only found git push --tags
.
Asked
Active
Viewed 6.8k times
2 Answers
213
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

Pavel Šimerda
- 5,783
- 1
- 31
- 31
-
3
-
2
-
`git push refs/tags/tag_a` and `git push --tags tag_a` both seem don't work. – Yad Smood Apr 22 '14 at 07:02
-
7OK, I figured it out. `git push remote_name refs/tags/tag_a` will work. I missed the remote name. – Yad Smood Apr 22 '14 at 07:06
-
1
-
@dirkk When without remote name we cannot push at all. Why you edit it back? – Yad Smood Apr 22 '14 at 08:21
-
Because your edit radically changed the answer and because it is incorrect in general. You can set a `push.default` (take a look at http://git-scm.com/docs/git-config), so this can work. However, you might want to add this information to the answer, which imho would add value to the answer. – dirkk Apr 22 '14 at 08:52
-
Is it actually possible to have a tag with the same name as a branch in a local repo? How is the local repo supposed to resolve the ambiguity in such a case? – Apr 22 '14 at 09:50
-
@YadSmood: Then I probably misunderstood and should revert my own edit as well. – Pavel Šimerda Apr 22 '14 at 10:04
-
@YadSmood: Your edit was indeed right, I made a very similar one now. – Pavel Šimerda Apr 22 '14 at 10:14
-
@Cupcake: Just tested. It works well. The local git is supposed to require the user to resolve the ambiguity by specifying `refs/tags/name` or `refs/heads/name`. – Pavel Šimerda Apr 22 '14 at 10:16
-
@dirkk: The former version of my answer didn't actually work (with a default setup at the least). `push.default` doesn't seem to make any change, here. – Pavel Šimerda Apr 22 '14 at 10:24
-
16
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 [<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 asrefs/tags/<tag>:refs/tags/<tag>
.

Walery Strauch
- 6,792
- 8
- 50
- 57