Skip to content

Instantly share code, notes, and snippets.

@Bat-Chat
Created July 11, 2016 15:07
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Bat-Chat/1d27ce1b5074a83ef8d43524c19b11b8 to your computer and use it in GitHub Desktop.
Save Bat-Chat/1d27ce1b5074a83ef8d43524c19b11b8 to your computer and use it in GitHub Desktop.
overriding old tag (move tag to latest commit)
Use the -f option to git tag:
-f
--force
Replace an existing tag with the given name (instead of failing)
You probably want to use -f in conjunction with -a to force-create an annotated tag instead of a non-annotated one.
Example
Delete the tag on any remote before you push
git push origin :refs/tags/<tagname>
Replace the tag to reference the most recent commit
git tag -fa <tagname>
Push the tag to the remote origin
git push origin master --tags
@hirasso
Copy link

hirasso commented Jun 13, 2023

🙏 Thanks, very helpful! Do you know a way to bypass the "tag message" when running git tag -fa ? I always want to throw out my computer if vim opens in my face 😄

@RoboMagus
Copy link

@hirasso add the -m flag for the message

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