fatal error when pushing TAG to server

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??


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
链接地址: http://www.djcxy.com/p/27148.html

上一篇: 找到一个项目是否在JavaScript数组中的最佳方法?

下一篇: 将TAG推送到服务器时发生致命错误