git: push only specific tags

AFAIK, git push --tag pushes every tags under refs/tags to remote. I want to know if there is a way in git to only push some tags that matches a wildcard or regexp?

For example, my repo has tag v1.0 , v1.1 , v2.0 and v2.1 . I want to only push v2.* . I tried

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

and got error

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

Of course, I can always do

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

But this does not smell gity.


git tag | grep '^v2.' | xargs --no-run-if-empty  git push <repo>
  • .git may not be directory, it may not be there at all. Submodules have there file pointing to root repository. Or you can have GIT_DIR set to somewhere else.
  • When no tags match your criteria, you do not want to do the push.
  • 链接地址: http://www.djcxy.com/p/27142.html

    上一篇: git:一个未注释的标签比一个注释不好的标签更糟?

    下一篇: git:只推送特定标签