Managing git tags like a pro

March 23, 2022

git
web
dev

Managing git tags can be a chore, especially when you make a mistake and tag a wrong commit. I found myself looking up the git commands way too often - and always finding some different results. It was annoying so I decided to write it down once and for all.

Here's the ultimate short guide to creating, moving, replacing and deleting git tags.

Creating a new tag locally

git tag <tag-name>

Pushing a local tag to origin

git push origin <tag-name>

Removing a local tag

git tag -d <tag-name>

Removing a remote tag

git push --delete origin <tag-name>

or

git push origin :refs/tags/<tag-name>

Moving an existing tag to the latest commit

First, remove a remote tag (see above) and then:

git tag -fa <tagname>