Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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.

like image 346
Peter Westlake Avatar asked Jun 20 '13 16:06

Peter Westlake


People also ask

Does git push include tags?

git push <remote> --tags will push both lightweight and annotated tags. There is currently no option to push only lightweight tags, but if you use git push <remote> --follow-tags only annotated tags will be pushed to the remote.

How do you push with tags?

Push all git tags to remote And if you want to push all tags from your local to the remote then add "--tags" to the git command and it will push all tags to the remote.

How do I add a tag to a pushed commit?

Right click on the commit you want to tag, and click Create Tag at this version... Back to Log Message dialog, right click on that tag label, click Push "tag_name"...


Video Answer


1 Answers

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.

like image 96
VonC Avatar answered Sep 29 '22 09:09

VonC