2

I have TFS GIT where my code base has been uploaded. I come from a TFS background where I am used to creating labels to create a snapshot of my code at any point in time. For TFS GIT, I found out that I need to create tags. However these tags only get created locally on my dev box.I want this tag to be pushed to the central repository but when I run this command on the command prompt:

git push origin MyTag

I get this error

fatal: MyTag cannot be resolved to branch.
Unexpected end of command stream

As far as I know, I am on the main branch, or the branch that gets created by default when you upload your code. I have not created any specific branches as such. How does one push a TAG from one dev box to the TFS server and then get it on another developer's box? I dont think creating a branch for every intended snapshot/label is a good idea.

Thoughts??

user20358
  • 14,182
  • 36
  • 114
  • 186
  • possible duplicate of [Push a tag to a remote repository using Git?](http://stackoverflow.com/questions/5195859/push-a-tag-to-a-remote-repository-using-git) – Daniel Mann Feb 10 '15 at 13:53
  • 2
    No its not a duplicate. That question was how to push a tag. I have tried the same command as explained there and got an error. I think I am passing the correct command as shown on that accepted answer. What else could be wrong? – user20358 Feb 11 '15 at 10:24

1 Answers1

4

When just asking for git push origin MyTag, git expects a branch name to be pushed and not a tag name (as it tells you in the error message).

In order to push a certain tag, you need to specify the exact tag name:

git push origin refs/tags/MyTag

or

git push origin tag MyTag

From man git-push:

The object referenced by <src> is used to update the <dst> reference on the remote side. By default this is only allowed if <dst> is not a tag (annotated or lightweight), and then only if it can fast-forward <dst>.
...
tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>.

If you want to push all your tags to origin, do

git push origin --tags
eckes
  • 64,417
  • 29
  • 168
  • 201