git:仅推送特定标签

标签 git tags

AFAIK,git push --tag 将 refs/tags 下的每个标签推送到远程。我想知道 git 是否有办法只推送一些匹配通配符或正则表达式的标签?

例如,我的仓库有标签 v1.0v1.1v2.0v2.1。我只想推送 v2.*。我试过了

git push <repo> refs/tags/v2.*

出现错误

fatal: remote part of refspec is not a valid name in refs/tags/v2.*

当然,我总能做到

cd .git && ls refs/tags/v2.* | xargs git push <repo>

但这并没有气味。

最佳答案

git tag | grep '^v2\.' | xargs --no-run-if-empty  git push <repo>
  • .git 可能不是目录,它可能根本不存在。子模块有指向根存储库的文件。或者您可以将 GIT_DIR 设置到其他地方。
  • 当没有标签符合您的条件时,您不想进行推送。

关于git:仅推送特定标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14784229/

相关文章:

ios - 检测来自哪个识别器的手势

git - mercurial (hg) 语法等同于 git 的 "^",表示在指定提交之前提交

linux - 混帐/Linux : What is a good strategy for maintaining a Linux kernel with patches from multiple Git repositories?

windows - 在 Windows 上连接到 GitHub 时出现问题,即使是通过 PuTTY

Swift - 以编程方式创建的按钮和标签相互链接

go - golang 中的这些//!+//!- 标签是什么?

git - 以确保干净/正确的工作树和子模块的方式更改分支 (Git)

javascript - 如何解决 Git 和 pdfmake-chinese 字体的问题?

Eclipse - 标记行以供以后编辑

html - i 标签的 Alt 或 title 属性