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

7 comments:

  1. Thanks. Very helpful

    ReplyDelete
  2. Thanks, Absolutely spot on, worked flawlessly.

    ReplyDelete
  3. VERY helpful - thank you!

    ReplyDelete
  4. Many thanks! Clean and concise

    ReplyDelete
  5. Beat stack overflow in my search 👍

    ReplyDelete
  6. Great and that i have a swell give: How Long Renovate House house renovation budget

    ReplyDelete