DEV Community

Michael Heap
Michael Heap

Posted on • Originally published at michaelheap.com on

Retag a Git Tag

The convention when building GitHub Actions is that you have a v1 tag that alway points at the latest release in the v1.x.x series. In most cases I’m using build-and-tag-action to handle this but in some cases I needed to retag things manually.

To update what a Git tag points to:

# Fetch existing tags
# -f is needed in case you previously had a tag.
# The action updates an existing tag, so we need to force pull
git fetch —tags -f

# Force update a tag
git tag -f v1.2.1 7585bee052d6780cc93dfe35bdc5f46baa29500d

# Force push this single tag
git push origin v1.2.1 --force
Enter fullscreen mode Exit fullscreen mode

If you’re updating a tag to point to another tag e.g. v1 = v1.2.3 you can use the new tag name as a reference:

git tag -f v1 v1.2.3
git push origin v1 --force
Enter fullscreen mode Exit fullscreen mode

Top comments (0)