Can we set a Git default to fetch all tags during a remote pull?

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?


A simple git fetch --tags worked for me.


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/*

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 <rbranch>:<lbranch> refspec, it refuses to update the local branch <lbranch> unless the remote branch <rbranch> it fetches is a descendant of <lbranch>. 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

For me the following seemed to work.

git pull --tags

It's simple. Do a

git fetch --all