git 远程标签未显示在本地

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17355477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:42:10  来源:igfitidea点击:

remote tag not shown in local

gitgit-tag

提问by user_stackoverflow

I am new to using git and tags. My team member ran the following commands:

我是使用 git 和标签的新手。我的团队成员运行了以下命令:

git tag v1.27.1
git push origin v1.27.1 

Now when I git pulland then run git tagin my environment, I expect to see a list of all the tags. I can see other tags that were pushed to repo in the similar way, but not this particular one. I want to find out how/where did this tag get lost. How can I do this? What should be my approach?

现在,当我git pull然后git tag在我的环境中运行时,我希望看到所有标签的列表。我可以看到以类似方式推送到 repo 的其他标签,但不是这个特定的标签。我想知道这个标签是如何/在哪里丢失的。我怎样才能做到这一点?我的方法应该是什么?

Also, my team member who created the tag can see the tag on his machine when he runs git tagThanks!

另外,我创建标签的团队成员在运行时可以在他的机器上看到标签git tag谢谢!

回答by John Szakmeister

Unfortunately, git pulldoesn't fetch tags by default. You need to run git fetch --tags, and then you'll have them.

不幸的是,git pull默认情况下不获取标签。你需要运行git fetch --tags,然后你就会拥有它们。

The default behavior of git pulland git fetchis to only retrieve tags that are directly accessible by the current references. If any tags are not, then those are not fetched. Passing --tagsto git fetchtells git that you want them all, whether they're reachable by current references or not.

的默认行为git pull,并git fetch是唯一的检索是由当前参考直接访问标签。如果没有任何标签,则不会获取这些标签。传递--tagstogit fetch告诉 git 你想要它们,无论它们是否可以通过当前引用访问。