Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k points)

Today I was looking through the logs for a project and realized that I fat-fingered a tag name some time ago. Is there some way to rename the tag? Google hasn't turned up anything useful.

I realize I could check out the tagged version and make a new tag, I even tried that. But that seems to create a tag object that isn't quite right. For one,

git tag -l

lists it out of order relative to all of the other tags. I have no idea if that's significant, but it leads me to believe that the new tag object isn't quite what I want. I can live with that, because I really only care that the tag name matches the documentation, but I'd rather do it "right", assuming there is a right way to do this.

1 Answer

0 votes
by (27.5k points)

In order to rename a tag 'old' to 'new', follow these steps:

$ git tag new old

$ git tag -d old

$ git push origin :refs/tags/old

$ git push --tags

Here, the colon ':' used in the push command removes the tag from the remote repository. If you don't do it, then git will create the old tag on your machine when you pull.

Note: In case you are working in a team, make sure that the other users remove the deleted tag as well. Don't forget to inform your co-workers to run the following command:

$ git pull --prune --tags

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...