[Git] Git Tag
Git Tag
- Semantic Versioning
- Viewing Tag
- Checking Out Tag
- Lightweight Tag
- Annotated Tag
- Tagging Previous Commit
- Forcing and Deleting Tag
- Pushing Tags
Semantic Versioning
- Standardized versioning system for software releases
- Consist of Three Digit (e.g. 2.4.1)
- Major Release(e.g. 2)
- Significant changes that are no longer backwards compatible.
- Features may be removed or changed substantially
- Minor Release(e.g. 4)
- New features or functionality have been added but is still backwards compatible
- The new functionality is optional and should not force users to rewrite their own code
- Patch Release(e.g. 1)
- Does not contain new features or significant changes
- Typically signify bug fixes and other changes that do not impact the the code is used
- Major Release(e.g. 2)
Viewing Tag
# view all tags
git tag
# filter by pattern(git tag -l "{pattern}")
git tag -l "*beta*" # contains beta
git tag -l "v1.0.0" # is exactly v1.0.0
Checking Out Tag
- Same as checking out to a specific commit
#checkout(git checkout {tag})
git checkout v1.0.0
# Comparing between two tags(git diff {tag1} {tag2})
git diff v1.0.0 v1.0.1
Lightweight Tag
- Single Name/label of a particular commit
# create lightweight tag(git tag {tagname})
git tag v1.0.0
Annotated Tag
- Stores extra meta data including author’s name, email, date, and tagging message etc.
# create annotated tag(git tag -a {tagname})
git tag -a v1.0.0
# see the message of the tag
git show v1.0.0
Tagging Previous Commit
# tag previous commmit(git tag {tag_name} {commit_has})
git tag v1.0.0 234s3s
Forcing and Deleting Tag
- Tag names cannot be duplicated
# force a tag to switch to another commit(git tag -f {tagname} {commit_hash})
git tag -f v1.0.0 234s3s
# delete a tag(git tag -d {tag_name})
git tag -d v1.0.0
Pushing Tags
- By default,
git push
doesn’t transfer tags to remote servers.
# push all tags to remote server
git push --tags
# push single tag(git push {remote_name} {tag_name})
git push origin v1.0.0
Deleting Remote Dag
# delete tag(git push origin :refs/tags/{tag_name})
git push origin :refs/tags/v1.0.0