Skip to content

Latest commit

 

History

History
72 lines (51 loc) · 1.26 KB

HowTo - Git Tag.md

File metadata and controls

72 lines (51 loc) · 1.26 KB

HowTo - Using Tags with Git

REF.: Git Book - 2.6 Git Basics - Tagging


Adding a New Tag

git tag <tagname>

Deleting a Tag

git tag -d <tagname>

Renaming a Tag

git tag <new_tagname> <old_tagname>

Renaming a Remote Tag

git push origin <new_tagname> :<old_tagname>

Note: The colon : removes the tag from the remote repository. Everyone else needs to update locally as well with git pull --prune --tags.

Editing an Existing Tag Message

# Replaces an existing tag with the same name and adds a message
git tag <tagname> <tagname>^{} -f -m "<new message>"

Listing Tags

git tag [--list or -l]
# or list with optional string pattern
git tag -l <pattern>
# or list with commit message
git tag -n

Tagging Later

# Tag a specific commit hash (with annotation)
git tag -a <tagname> 9fceb02
# ... (without annotation, a light-weight tag)
git tag <tagname> 9fceb02

Sharing Tags Remotely

git push origin <tagname>
# or sharing all tags at once
git push origin --tags
# not recommended; this might trigger unwanted actions (!)

Deleting a Remote Tag

git push origin --delete <tagname>