git 如何查看远程标签?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25984310/
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
How to see remote tags?
提问by cprcrack
In Atlassian SourceTree, how to know which tags are only local and which are also in remote?
在 Atlassian SourceTree 中,如何知道哪些标签仅在本地,哪些也在远程?
When creating a tag you get the option "Push tag to: ...", but how to know if a tag has been pushed or not after it is created? I can see all my tags locally, but I need to be sure that they are present in remote so that other developers can pull them.
创建标签时,您会看到“将标签推送到:...”选项,但是如何知道标签在创建后是否已被推送?我可以在本地看到我的所有标签,但我需要确保它们存在于远程,以便其他开发人员可以提取它们。
采纳答案by VonC
Even without cloning or fetching, you can check the list of tags on the upstream repo with git ls-remote
:
即使没有克隆或获取,您也可以使用以下命令检查上游存储库上的标签列表git ls-remote
:
git ls-remote --tags /url/to/upstream/repo
(as illustrated in "When listing git-ls-remote why there's “^{}
” after the tag name?")
(如“列出 git-ls-remote 时为什么^{}
标签名称后面有“ ”? 中所示)
xbmonoillustrates in the commentsthat quotes are needed:
git ls-remote --tags /some/url/to/repo "refs/tags/MyTag^{}"
Note that you can always push your commits andtags in one command with (git 1.8.3+, April 2013):
请注意,您始终可以使用(git 1.8.3+,2013 年 4 月)在一个命令中推送您的提交和标签:
git push --follow-tags
See Push git commits & tags simultaneously.
请参阅同时推送 git 提交和标签。
Regarding Atlassian SourceTree specifically:
具体关于 Atlassian SourceTree:
Note that, from this thread, SourceTree ONLY shows local tags.
请注意,从此线程中,SourceTree 仅显示本地标签。
There is an RFE (Request for Enhancement) logged in SRCTREEWIN-4015
since Dec. 2015.
SRCTREEWIN-4015
自 2015 年 12 月以来,有一个 RFE(增强请求)登录。
A simple workaround:
一个简单的解决方法:
see a list of only unpushed tags?
查看只有未推送标签的列表?
git push --tags
or check the "
Push all tags
" box on the "Push" dialog box, all tags will be pushed to your remote.
git push --tags
或选中
Push all tags
“推送”对话框中的“ ”框,所有标签都将被推送到您的遥控器。
That way, you will be "sure that they are present in remote so that other developers can pull them".
这样,您将“确保它们在远程存在,以便其他开发人员可以拉动它们”。
回答by Landys
You can list the tags on remote repository with ls-remote
, and then check if it's there. Supposing the remote reference name is origin
in the following.
您可以使用 列出远程存储库上的标签ls-remote
,然后检查它是否存在。假设远程引用名称origin
如下。
git ls-remote --tags origin
And you can list tags local with tag
.
您可以使用tag
.
git tag
You can compare the results manually or in script.
您可以手动或在脚本中比较结果。