Skip to content

Instantly share code, notes, and snippets.

@mrk-han
Created March 9, 2020 18:09
Show Gist options
  • Save mrk-han/37fc932f9d41c2affb5ef76bd18c69d5 to your computer and use it in GitHub Desktop.
Save mrk-han/37fc932f9d41c2affb5ef76bd18c69d5 to your computer and use it in GitHub Desktop.
If you need to tag a new commit, but haven't published to Maven Central yet

How to change a Git tag to reference a new commit

If you accidentally tag the wrong commit, or if you have a new commit before publishing then you may be able to re-tag without incrementing your library's version #

Delete Remote Tag

git push origin :refs/tags/0.21.0

Delete Local Tag

git tag -d 0.21.0

Tag New Commit

git tag 0.21.0 e242d7263481a2a375f3f2b38c3cf849ddbce457

Push New Tag to Remote

git push origin 0.21.0

Old Release on Github turns into a DRAFT

When I deleted the remote tag, the release lost its reference to the tag, so it reverted from a Release to a Draft Release. Navigate to Release and re-release on Github

Context: I had tagged a commit but there was an error in the Gradle Publish task. I had to push a commit to fix this but had already "released" a tag on Github. I didn't want to increment the version so these were the steps I took.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment