If there are tags in the remote repository, I’m usually getting them automatically when pulling. When I delete the created local tag (git tag -d <tag-name>) and pull, the deleted tag will be recreated. I can delete remote branches/tags (git push <remote-branch/tag-name>:<branch/tag-name>), but how can I detect that the local tag was created by fetching a remote tag?
If there are tags in the remote repository, I’m usually getting them automatically when
Share
If you’re annoyed about these tags being recreated when you run
git pull, you turn off the fetching of tags by default with the remote.<remote-name>.tagopt config setting. e.g. if the remote isorigin, then you can do:Update: to address your comment, the reason that I suggest this is that there’s not an obvious way to tell the difference between a tag that was created locally and one that was fetched from a remote. There’s also no
reflogfor tags. So, my suggestion is to suppress automatic fetching of tags – you can then fetch them yourself into a different namespace. For example, you could do:… and perhaps create an alias for that. Then when you want to fetch tags, they’ll be named, for example,
refs/tags/origin/tag1instead ofrefs/tags/tag1.If you want this to happen automatically, you could change your
.git/configto list multiple refspecs for fetching, e.g.:… which is suggested in Pro Git.