I currently have a git remote setup like the following:

[remote "upstream"]
    url = <redacted>
    fetch = +refs/heads/*:refs/remotes/upstream/*

When I issue git pull on branch master, all remote heads are fetched into remotes/upstream, then remotes/upstream/master is merged into master. Any tags that can be reached are also fetched at the same time, which is very convenient.

I'd like git pull to additionally fetch all tags from the remote, not just those that are directly reachable from the heads. I originally tried seting tagopt == --tags, but found this caused only tags to be fetch and thus broke everything. (Junio even says that's a horrendous misconfiguation).

Is there a way to make git pull fetch all remote tags by default, in addition to the remote heads?

share|improve this question
    
A reminder to myself: Make sure you actually pushed the tag first (does not work automatically): git push origin <tag_name> – Hafenkranich Apr 26 '17 at 0:40
up vote 38 down vote accepted

You should be able to accomplish this by adding a refspec for tags to your local config. Concretely:

[remote "upstream"]
    url = <redacted>
    fetch = +refs/heads/*:refs/remotes/upstream/*
    fetch = +refs/tags/*:refs/tags/*
share|improve this answer
1  
Aha, I never realized you could have multiple fetch lines, I presumed the last one would just override. That's very nice and explicit. – jleahy May 21 '13 at 19:54

A simple git fetch --tags worked for me.

share|improve this answer
1  
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Fizzix Jan 12 '15 at 23:05
6  
@Fizzix Perhaps the title should be altered to include "by default". This post answered my question. – Matt Kneiser Nov 1 '16 at 22:20
    
This did not work for me. I can see the tags with git ls-remote. – dangeroushobo 2 days ago

The --force option is useful for refreshing the local tags. Mainly if you have floating tags:

git fetch --tags --force

The git pull option has also the --force options, and the description is the same:

When git fetch is used with : refspec, it refuses to update the local branch unless the remote branch it fetches is a descendant of . This option overrides that check.

but, according to the doc of --no-tags:

By default, tags that point at objects that are downloaded from the remote repository are fetched and stored locally.

If that default statement is not a restriction, then you can also try

git pull --force
share|improve this answer

It's simple. Do a

git fetch --all

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.