How to overwrite local tags with git fetch?
git fetch --tags
will do it.
From the docs (description of the --tags
parameter):
Most of the tags are fetched automatically as branch heads are downloaded, but tags that do not point at objects reachable from the branch heads that are being tracked will not be fetched by this mechanism. This flag lets all tags and their associated objects be downloaded. The default behavior for a remote may be specified with the remote.<name>.tagopt setting.
As per gerrard00's answer, the --force
parameter is necessary to overwrite local tags in git Ver2.20 or newer. (The full command being git fetch --tags --force
)
git fetch --tags --all --prune
This will explicitly tell git to fetch, and at the same time, remove tags which no longer exist on the remote.
As of Git 2.2.0 you need to explicitly specify the force flag:
git fetch origin --tags --force
Until Git version 2.20, and unlike when pushing with git-push[1], any updates to refs/tags/* would be accepted without + in the refspec (or --force). When fetching, we promiscuously considered all tag updates from a remote to be forced fetches. Since Git version 2.20, fetching to update refs/tags/* works the same way as when pushing. I.e. any updates will be rejected without + in the refspec (or --force).
https://git-scm.com/docs/git-fetch