Tuesday, November 25, 2014

Update the existing git tag in remote repository

Generally GIT tags are used to mark release points. Every time we make a
release in our project, we tag it using the command:

git tag -a VER_7_5_0 -m "Version 7.5.0 tagged"

then push it to central repository to share with others.

git push --tags

Often times this tag has to be altered to include/exclude a fix from the
release, before make it to the customer.

Here are the steps to update the existing tag in remote repository:

Step 1: Update a tag in local repository using -f option.

git tag -a -f VER_7_5_0 -m "Version 7.5.0
tagged"

Step 2: Remove a tag from remote repository.

git push origin :refs/tags/VER_7_5_0

Step 3: Push the updated tag to remote repo.

git push --tags

To view remote tags:

git ls-remote --tags origin

Caution: If someone
already pulled your tags into their local repo, they will not get the updated
one unless they delete the old one. If you are not sure about this, you better
create a new tag instead of updating the existing one.