11

We created lots of tags before we discovered that git tags can be named with slashes to get them arranged in a folder structure. Now it is really hard to get rid of the misnamed tags, because although I delete the misnamed tags on the server, suddenly someone that haven't deleted their tags locally pushes all tags and then both old and new tags are on the server again.

We're using SourceTree as git client (and yes, I've been around and made sure that everyone have unchecked the "push all tags" checkbox, but new people arrive and computers are replaced) and Visual Studio Team Services Git repo.

I want everyone to be able to create and push tags individually, I just want to avoid those bulk pushes of tags.

I've read this post git pre-push hook, don't run if is --tags but the solution doesn't seem to work in Windows.

5
  • 'I've been around and made sure that everyone have unchecked the "push all tags" checkbox'—maybe you should go around and ask people delete the obsolete tags. But are they really so bothersome? What's the big deal about having some old tags in your repository?
    – Chris
    Commented Aug 14, 2017 at 18:58
  • True, I could do that, but it means administration that I don't have the time to do really. And it will probably sneak in new tags in wrong format later on that will need renaming/deletion. Well, I guess we could live with them, but I think most of us like to have it tidy and it's easier to navigate to an old tag when they are nicely structured in SourceTree. Commented Aug 14, 2017 at 20:10
  • Figure out how you can set up rules on your hosted repository to prevent pushing of refs matching a specific pattern. We had the same problem and no matter how many times we took the round it only took 1 stray developer that wasn't paying attention and everybody had the tags yet again. In the end I pushed up the correct list of tags and prevented people from pushing refs/tags/* to our server, this finally made the onslaught stop. Commented Aug 15, 2017 at 6:48
  • @LasseV.Karlsen So far it isn't possible to set up the needed git hooks in Team Services. Commented Aug 15, 2017 at 19:16
  • @LasseV.Karlsen Do you know by any chance how what you did can be done in GitHub via webhooks or maybe actions? Thanks! Commented Jun 25, 2020 at 15:54

1 Answer 1

9

No matter git hooks or other scripts, all of them need to run on the local machines individually. So I will suggest to sync tags with remote before the developers create their own tags on local machines.

Actually it just need to execute once for each local machine, so the developers just need to run below commands (delete local tags and get all tags from remote) on their machine before working:

git tag -l | xargs git tag -d
git fetch --tags

Then the developers can work on their own local repo and even git push with push all tags option selected in SourceTree won’t effect the old tags you deleted.

Additional, when the server side hooks will available in future for VSTS, you can also use post-push hooks to check if the deleted tags are pushed to remote again. If yes, stop to push the certain tag(s) you specified in post-push hook.

1
  • Yes, sadly this seems to be the only option. And I thought I did exactly that, but somehow a single developer had the old tags anyway and pushed them... Until Team Services has more usable git hooks I'll continue to educate and administrate. Commented Aug 15, 2017 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.