DEV Community

Michael Heap
Michael Heap

Posted on • Originally published at michaelheap.com on

1

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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs