Is there a way to keep my local git tags in lockstep with a remote\'s tags? That is -- not only get new tags when created (as usual, when fetch
-ing/pull
disclaimer this uses git internals (some may argue that the filesystem is a git interface, but that's for another day :D)
# Blow away all local tags, this will remove any that are tagged locally
# but are not on the remote
rm .git/refs/tags/*
# Download all the tags from the remote
git fetch --tags
Here's an alternative solution:
git fetch -p +refs/tags/*:refs/tags/*
From the git fetch doc:
-p --prune
Before fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning.