git 标签也会被推送吗?
自从我创建了我的存储库以来,我所使用的标签似乎 创建不会被推送到存储库。当我在上执行 git tag
时 本地目录所有标签都存在,但是当我登录到 远程存储库并执行 git tag
,仅显示前几个。
可能是什么问题?
Since I created my repository it appears that the tags I have been
creating are not pushed to the repository. When I do git tag
on the
local directory all the tags are present, but when I logon to the
remote repository and do a git tag
, only the first few show up.
What could the problem be?.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你可以这样做:
You could do this:
在默认的 git 远程配置中,您必须显式推送标签(同时它们自动获取以及它们指向的提交)。您需要使用
推送单个标签,或
推送所有标签(或
git push --tags
推送到默认远程,通常origin
)。这是非常有意的行为,以使推送标签变得明确。推送标签通常应该是有意识的选择。
总结 Junio C. Hamano 写道(在@Andre Miras 的评论中链接)
这就是为什么
git fetch
自动“跟随”标签,即在下载它们指向的修订版时下载标签 - 换句话说,下载所有相关的已发布标签。这就是为什么您需要显式推送标签,将标签标记为公共。
或者,您可以将推送的远程配置为始终推送所有标签,例如在您的
.git/config
中放入类似的内容:这意味着强制推送所有头(所有分支) )和所有标签(如果您不想强制推动头部,请从 refspec 中删除“+”前缀)。
In default git remote configuration you have to push tags explicitly (while they are fetched automatically together with commits they point to). You need to use
to push a single tag, or
to push all tags (or
git push --tags
to push to default remote, usuallyorigin
).This is very much intended behavior, to make pushing tags explicit. Pushing tags should be usually conscious choice.
Summarizing what Junio C. Hamano wrote (linked in comments by @Andre Miras)
That's why
git fetch
automatically "follows" tags, i.e. it downloads tags when downloading revisions they point to - in other words downloads all relevant published tags.That's why you need to push tag explicitly, to mark tag as public.
Alternatively you can configure the remote you push to to always push all tags, e.g. put something like that in your
.git/config
:This means force push all heads (all branches) and all tags (if you don't want force pushing of heads, remove '+' prefix from refspec).
请注意,自 git 1.8.3(4 月22d, 2013),你不再需要执行 2 个命令来推送分支,然后推送标签:
现在,您可以在推送新提交时尝试:
但这不会推送所有本地标记,只会推送使用
推送的提交引用的带注释标记git 推送
。这是由 commit c2aba15 引入的。 com/gitster" rel="noreferrer">Junio C Hamano (
gitster
):默认情况下,配置
push.followTags
允许包含--follow-tags
(Git 2.4.1+,2015 年第 2 季度)。请参阅“同时推送 git 提交和标记”
Note that since git 1.8.3 (April 22d, 2013), you no longer have to do 2 commands to push branches, and then to push tags:
You can now try, when pushing new commits:
That won't push all the local tags though, only the annotated ones referenced by commits which are pushed with the
git push
.This has been introduced in commit c2aba15 by Junio C Hamano (
gitster
):The config
push.followTags
allows to include--follow-tags
by default (Git 2.4.1+, Q2 2015).See "Push git commits & tags simultaneously"
我通常做的是:
这意味着它会推送已经存在的每个分支以及标签。它不会强制推送,也不会推送您未手动推送的分支。
What I usually do is :
Meaning it pushes every branch that's already there, plus tags. It does not force push, and it does not push branch that you didn't push manually.
如果您想强制获取所有标签,您可以通过以下方式在配置中设置:
来自文档:
And if you want to force fetch all the tags, you may set it in the config by:
From the docs: