Do git tags get pushed as well?
自从我创建了我的存储库之后,我的标签创建不会被推送到存储库中。当我在本地目录所有标记都存在,但当我登录到远程存储库和做一个
问题可能是什么?.
你可以这样做:
1 | git push --tags |
在默认的git远程配置中,您必须显式地推送标记(当它们与它们指向的提交一起自动提取时)。你需要使用
1 | $ git push <remote> tag <tagname> |
号
推一个标签,或
1 | $ git push <remote> --tags |
推送所有标签(或
这是非常有意的行为,以使推送标记显式化。推标签通常是有意识的选择。
总结Junio C.Hamano所写的内容(链接到@andre miras的评论中)
When fetching, you are interacting with a remote repository somebody has published, which means:
the set of tags that exist there are all the publisher wanted people to see, and not only you but other people will also see the same tags. In other words, tags in repositories you fetch from are designed to be public and shared. It will facilitate communication between developers if it is easy for everybody to fetch these same tags.
号
这就是为什么
When pushing, you are pushing from your working repository, which most of the time is not public, and tags in that repository is not designed to be public. You can use your own local tags to mark your progress, so it does not make sense to blindly push all tags in your repository to the repository you are pushing to publish your changes, whose tags are by definition public.
号
这就是为什么需要显式地推送标记,将标记标记标记为公共的原因。
或者,您也可以将您所推的遥控器配置为始终推送所有标签,例如在您的
1 2 3 4 | [remote"publish"] # or whatever it is named url = ... push = +refs/heads/*:refs/heads/* push = +refs/tags/*:refs/tags/* |
。
这意味着强制推送所有头(所有分支)和所有标记(如果不希望强制推送头,请从refspec中删除"+"前缀)。
请注意,由于git 1.8.3(2013年4月22日),您不再需要执行两个命令来推送分支,然后再推送标签:
The new"
--follow-tags " option tells"git push " to push relevant annotated tags when pushing branches out.
号
现在,您可以在推送新提交时尝试:
1 | git push --follow-tags |
。
但是,这不会推送所有的本地标签,只会推送提交引用的带注释的标签,这些标签是用
这一点已由Junio C Hamano(
The new option"
--follow-tags " tells"git push " to push annotated tags that are missing from the other side and that can be reached by the history that is otherwise pushed out.For example, if you are using the"
simple ","current ", or"upstream " push, you would ordinarily push the history leading to the commit at your currentHEAD and nothing else.
With this option, you would also push all annotated tags that can be reached from that commit to the other side.
号
配置
我通常做的是:
1 2 3 4 | [remote"publish"] # or whatever it is named url = ... push = : push = +refs/tags/*:refs/tags/* |
。
这意味着它会推动已经存在的每个分支,加上标签。它不会强制推,也不会推您没有手动推的分支。
如果要强制获取所有标记,可以通过以下方式在配置中设置:
1 | git config remote.origin.tagopt --tags |
从文档中:
Setting this value to --no-tags disables automatic tag following when fetching from remote . Setting it to --tags will fetch every tag
from remote , even if they are not reachable from remote branch
heads. Passing these flags directly to git-fetch(1) can override this
setting. See options --tags and --no-tags of git-fetch(1).
号