git - 将 TAG 推送到服务器时发生 fatal error

标签 git tfs

我有 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 as refs/tags/<tag>:refs/tags/<tag>.

如果您想将所有标签推送到 origin ,做

git push origin --tags

关于git - 将 TAG 推送到服务器时发生 fatal error ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28433004/

相关文章:

git - 从远程 pull 时快进意味着什么?

c# - 添加 C++ 项目时出现 CS1705 错误解决方案

tfs - 如何以编程方式将文件附加到 TFS 工作项

windows - 在 Windows 上使用无效字符提交 Git

git - GnuTLS接收错误(-110): The TLS connection was non-properly terminated

powershell - 抑制 powershell 输出消息

TFS 2012 未将转换后的 Web.Config 复制到 _PublishedWebsite

git - 在 TFS 2017 托管存储库上设置默认分支

git - git 工作流的特征分支统计

git - 在预推送中提交以更新版本