Github - Moving Tags

By Samuel Molinski, 17 April, 2024
A digital illustration for a blog article featuring a developer sitting at a computer, manipulating Git tags. The scene shows a modern office environment with dual monitors displaying command line interfaces, one showing 'git push --delete origin v2.2' and the other 'git fetch --all --tags --force'. The developer, a middle-aged Caucasian man with short brown hair, is focused on his screen, surrounded by coding books and a coffee cup on his desk. The overall mood is of concentration and technology at work.

Recently, I began exploring using Github releases. I quickly wanted to update a release tag attached to a particular commit. There isn't a tag-move command, so we must remove it and add it back. Additionally, pushing those changes to the different repos.

To remove the tag from the local repo

git tag --delete <tagname>

Example:

git tag --delete v2.2

To remove the tag from the remote repo

git push --delete origin <tagname>

Example:

git push --delete origin v2.2

This worked fine; I could adjust the tag in my local and origin repos. The additional issue became that the server's local repo was not updating.  To ensure all the tags in the local repo are updated, and any deleted tags are removed, you can use the command:

git fetch --all --tag --force 

In summary, use git push --delete for the remote and git tag --delete for the local, coupled with a forceful fetch, provides a comprehensive approach to tag management in distributed environments.

 

Comments