How to overwrite local tags with git fetch?

How to overwrite local tags with git fetch? I want to replace local tags with deleted tags.

+7
source share
4 answers

git fetch --tags will do this.

From docs (description of the --tags parameter):

Most tags are automatically selected as branch heads are loaded, but tags that do not indicate objects that are accessible from tracked branch branches will not be retrieved by this mechanism. This flag allows you to load all tags and related objects. The default behavior for the remote can be set using the remote..tagopt setting.

+3
source

git fetch --tags --all --prune

This will explicitly tell git to select and at the same time remove tags that no longer exist on the remote control.

+4
source

Firstly, unlike branches, git does not track remote tags other than local tags. After sampling, they are indistinguishable.

  • updates the local tag (even if the manual does not report)
    • git fetch --tags
  • does not update the local tag
    • git fetch
    • git fetch --prune
    • git fetch --prune --force

Tag update / rewrite is as follows:

 From git:path/name - [tag update] my_tag -> my_tag 

This works for light and annotated tags, even mixed ones. That is: an annotated tag can be overwritten with light and vice versa.

I used git version 2.7.4

0
source

Tags will not be overwritten because they must be unshakable. If you want the object to (realistically) change, use the branch pointer or ref instead. This leaves you with the git -d tagname ... tag and then retrieves it again.

-one
source

All Articles