Saturday, October 18, 2014

How to rename a GIT tag in the remote repo?

Some times we would have added a tag, pushed it to remote and then realized that we’d named it wrong. 
Ex. VER_7_2_0 instead of VER_7_1_2. 

Here is quick tip to rename a git tag in the remote repo. 

Step 1: Create a new tag on the same commit point of old tag and push it, 
git tag new_tag old_tag 
git push --tags 

Step 2: Delete the old tag from local repo. 
git tag -d old_tag 

Step 3: Delete the old tag from remote repo. 
git push origin :refs/tags/old_tag 

You can verify the changes made, by executing the below command. It shows all remote tags: 
git ls-remote --tags origin

No comments:

Post a Comment