git - 如何使 "git push"在分支中包含标签?

标签 git

当获取单个分支时,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.

有没有办法让 git push 的行为相同?手册页说明了如何不推送标签(默认)、所有标签(--tags)或您在命令行中命名的标签。它没有提供将所有指向分支的方法推送。

最佳答案

您可以尝试使用 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.

这不会推送所有标签,而只会推送可从您推送的分支 HEAD 访问的标签。

如“Push a tag to a remote repository using Git? ”中所述,这仅涉及 annotated tags ,而不是轻量级标签。

git tag 1.0(轻量级)不会用 --follow-tags 推送,它会用 git push --tags


使用 Git 2.4.1+(2015 年第 2 季度),该选项可以设置为默认值。

参见 commit a8bc269通过 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::

If set to true enable '--follow-tags' option by default. You may override this configuration at time of push by specifying '--no-follow-tags'

请全局启用此设置,您可以运行 git config --global push.followTags true。它也可以在每个存储库的基础上指定。

关于git - 如何使 "git push"在分支中包含标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17219102/

相关文章:

git - 从旧提交中删除文件而不影响 gitlab 中的任何其他提交

Git pull 请求 : dev into master without a new commit

Git 提示和技巧 : Display Branch on Command Prompt not working and created side effects of git branch function not working and many others

Git 恢复未提交的更改

python - 如何将代码从 Git 更新到 Docker 容器

python - AWS Elastic Beanstalk 无法使用 requirements.txt Git Pip 安装 Python 包

git - 是否可以将 git 提交 Hook 到 Textmate 上的保存?

即使分支的更改已应用到 master,git branch -d 也会失败

git - 从 GitHub 上已删除的复刻中恢复作为 pull 请求发送的提交

java - 使用 JGit,“In CorrectObjectTypeException : Object . ...不是一棵树