How to make "git push" include tags within a branch?

When fetching a single branch, git fetch includes any tags that point into the branch:

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.

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.


You can try, with git1.8.3+ (May 2013):

git push --follow-tags

The new " --follow-tags " option tells " git push " to push relevant annotated tags when pushing branches out.

This won't push all the tags, but only the ones accessible from the branch(es) HEAD(s) you are pushing.

As mentioned in "Push a tag to a remote repository using Git?", this concerns only annotated tags, not lightweight tags.

git tag 1.0 (lightweight) would not be pushed with --follow-tags , it would with git push --tags .


With Git 2.4.1+ (Q2 2015), that option can be set as default.

See commit a8bc269 by 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.

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 '

Do enable this setting globally, you can run git config --global push.followTags true . It can also be specified on a per repository-basis.

链接地址: http://www.djcxy.com/p/27138.html

上一篇: GitHub中的发布到底是什么?

下一篇: 如何让“git push”在分支中包含标签?