我有 TFS GIT,我的代码库已上传到其中。我有 TFS 背景,习惯于创建标签以在任何时间点创建代码快照。对于TFS GIT,我发现我需要创建标签。但是,这些标签仅在我的开发盒上本地创建。我希望将此标签推送到中央存储库,但是当我在命令提示符下运行此命令时:
git push origin MyTag
我收到此错误
fatal: MyTag cannot be resolved to branch.
Unexpected end of command stream
据我所知,我位于主分支,或者是您上传代码时默认创建的分支。我还没有创建任何特定的分支。如何将 TAG 从一个开发者设备推送到 TFS 服务器,然后将其获取到另一开发者设备上?我不认为为每个预期的快照/标签创建一个分支是一个好主意。
想法??
最佳答案
当只是询问git push origin MyTag
时,git 期望推送一个分支名称,而不是标签名称(正如它在错误消息中告诉您的那样)。
为了推送某个标签,您需要指定确切的标签名称:
git push origin refs/tags/MyTag
或
git push origin tag MyTag
来自 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 asrefs/tags/<tag>:refs/tags/<tag>
.
如果您想将所有标签推送到 origin
,做
git push origin --tags
关于git - 将 TAG 推送到服务器时发生 fatal error ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28433004/