Reputation: 4830
We're currently cleaning up our git repo at work due to a ridiculous amount of branches and tags that just aren't needed.
We've done the branches part, but the tags part is proving troublesome.
We deleted the branches on the remote, and asked our team to do a git pull --prune
to remove said branches in their local repos.
The problem is, there doesn't seem to be a way to do this with tags. We can delete the tag remotely quite easily, but we can't get that change to propagate down to other local repos when we do a git pull
, or gc
, or remote prune
.
Any ideas on how to do this?
Or will we just have to stop people from using git push --tags
until they re-clone the repo?
Upvotes: 13
Views: 2654
Reputation: 170
In older versions of Git this seems to work fine:
git fetch --tags --prune
(But this no longer works as of Git version 1.9.0 or newer.)
Upvotes: 10
Reputation: 4402
Because "git fetch --tags --prune" is not working for me I put che 's solution into an alias which works fine for me:
# update tags
ut = "!sh -c 'for tag in $(git tag); do git tag -d ${tag}; done; git fetch --tags'"
Upvotes: 0
Reputation: 12273
I don't think there's an easy way to delete the tags with push, but you can instruct your people to delete all their local tags
for tag in $(git tag); do git tag -d ${tag}; done
and then fetch from main repo to sync those that should stay alive.
I don't see any reason to push tags by default, as tags in git are pretty indestructible and usually done only for releases as similar important milestones.
Upvotes: 4