How to Tag in GIT

TAGGING A GIT BRANCH

Show all tags

git tag

Search tag

git tag -l "tag-search-pattern"
E.g.
git tag -l "v2.0.2*"

Create annotated tag

git tag -a <tagname> -m "<message>"
E.g.
git tag -a v2.0 -m "This version 2.0 contains web-ui changes"

Show tag details

git show <tagname>
E.g.
git show v2.0

Checkout tags

git checkout -b <branchname> <tagname>
E.g.
git checkout -b version2.0 v2.0

Pushing tags to remote

git push origin <tagname>
E.g.
git push origin v2.0

Pushing all (un-pushed) tags to remote

git push origin --tags

Rename an annotated git tag

  • rename tag
git tag <new-tag> <old-tag>
E.g.
git tag v1.1 1.1
  • delete tag locally
git tag -d <old-tag>
  • push deleted tag-change to remote
git push origin :<old-tag>
E.g.
git push origin :refs/tags/1.1
OR
git push origin :1.1
  • push renamed tag to remote
git push origin <new-tag> (E.g. git push origin v1.1)
OR
git push --tags
  • Finally, make sure that the other users remove the deleted tag. Please tell them(co-workers) to run the following command:
git pull --prune --tags

List local branches with corresponding HEAD hash, sorted by last commit date

git for-each-ref --sort=-committerdate refs/heads/

* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.

Leave a Reply

Your email address will not be published. Required fields are marked *