gpt4 book ai didi

git - 将 TAG 推送到服务器时出现 fatal error

转载 作者:太空狗 更新时间:2023-10-29 14:38:00 27 4
gpt4 key购买 nike

我有 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 期望推送一个 branch 名称而不是 tag 名称(正如它在错误消息中告诉您的那样)。

为了推送某个标签,您需要指定确切的标签名称:

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com