如何使“git push”在分支中包含标签?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17219102/
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 make "git push" include tags within a branch?
提问by Peter Westlake
When fetching a single branch, git fetch
includes any tags that point into the branch:
获取单个分支时,git fetch
包含指向该分支的任何标签:
When refspec stores the fetched result in remote-tracking branches, the tags that point at these branches are automatically followed. This is done by first fetching from the remote using the given s, and if the repository has objects that are pointed by remote tags that it does not yet have, then fetch those missing tags. If the other end has tags that point at branches you are not interested in, you will not get them.
当 refspec 将获取的结果存储在远程跟踪分支中时,会自动跟踪指向这些分支的标签。这是通过首先使用给定的 s 从远程获取来完成的,如果存储库具有由远程标签指向的对象,而它尚未拥有,则获取那些缺少的标签。如果另一端的标签指向您不感兴趣的分支,您将无法获得它们。
Is there any way to make git push
behave the same way? The man page says how to push no tags (the default), all tags (--tags
), or ones you name on the command line. It doesn't give a way to push all the ones pointing into the branch.
有没有办法使git push
行为相同?手册页说明了如何推送无标签(默认)、所有标签 ( --tags
) 或您在命令行中命名的标签。它没有提供将所有指向分支的方法。
回答by VonC
You can try, with git1.8.3+(May 2013):
您可以尝试使用git1.8.3+(2013 年 5 月):
git push --follow-tags
The new "
--follow-tags
" option tells "git push
" to push relevant annotated tags when pushing branches out.
新的 "
--follow-tags
" 选项告诉 "git push
" 在推出分支时推送相关的注释标签。
This won't push allthe tags, but only the ones accessible from the branch(es) HEAD(s) you are pushing.
这不会推送所有标签,而只会推送可从您推送的分支 HEAD 访问的标签。
As mentioned in "Push a tag to a remote repository using Git?", this concerns only annotated tags, not lightweight tags.
如“使用 Git 将标签推送到远程存储库?”中所述,这仅涉及带注释的标签,而不是轻量级标签。
git tag 1.0
(lightweight) would not be pushed with --follow-tags
, it would with git push --tags
.
git tag 1.0
(轻量级)不会被推入--follow-tags
,而是被推入git push --tags
。
With Git 2.4.1+ (Q2 2015), that option can be set as default.
在 Git 2.4.1+(2015 年第二季度)中,可以将该选项设置为默认值。
See commit a8bc269by Dave Olszewski (cxreg
):
make it easier to add new configuration bits and then add
push.followTags
configuration that turns--follow-tags
option on by default.
可以更轻松地添加新的配置位,然后添加默认情况下
push.followTags
打开--follow-tags
选项的配置。
The documentation will include:
文件将包括:
push.followTags::
If set to true enable '
--follow-tags
' option by default. You may override this configuration at time of push by specifying '--no-follow-tags
'
如果设置为 true
--follow-tags
,则默认启用 ' ' 选项。您可以通过指定“--no-follow-tags
”在推送时覆盖此配置
Do enable this setting globally, you can run git config --global push.followTags true
. It can also be specified on a per repository-basis.
请全局启用此设置,您可以运行git config --global push.followTags true
. 它也可以在每个存储库的基础上指定。