Thursday, July 19, 2012

"Amend" a tag in git


When creating a tag in git, you sometimes notice 5 seconds later that you forgot to add a file or that you introduced a small problem. This "premature tagulation" happens to me all the time.

When I initially look for how to do this, I had just read about "amending a commit", so my natural thought process was to Google for "amend a tag in git". This isn't the right way to label this, so I'm posting for anyone that's following my incorrect line of thinking.

What you really want to do is create a new tag with same name.

git tag -a my_tag_name

With no arguments, this returns:

fatal: tag 'my_tag_name' already exists


You need to force the tag, which tells git to "put the sticky label" for the tag on another revision

git tag -a my_tag_name -f 


which does what you want.

1 comment: