Git tags
Last updated
Last updated
Tags are pointers that refer to particular point in git history. We can mark a particular moment in time with a tag. Tags are most often used to mark version releases in projects (v 4.1.0, v4.1.1, etc)
Think of tags as branch references that do not change. once a tag is created, it always refers to the same commit . It's just a label for a commit .
There are two types of Git tags we can use : lightweight and annotabted tags .
lightweight tags are ..lightweight. They are just a name/label that points to a particular commit .
annotated tags store extra meta data including the author's name and email, the data,and a tagging ,essage (like a commit message)
The semaintic versioning spec outlines a standardized versionning system for software releases. It providers a consistent way for developers to give meaning to their software releases. (how big of a changes is this release)
Version consist of three number separated by periods
typically, the first release is 1.0.0
Path releases normailly do not contain new features or significantly change. They typically signnify bug fixes and other changes that do not impact how the code is used.
Minor release signify that new features or functionality have been added ,but the project is still backward compatible.No breaking changes .THe news functionality is optional and should not force users to rewrite their own code.
Major release signify that signify signifycant changes that is no longer backward compatible. Feature may be removed or changhed subsitaintially
Git tag
git tag will print a list of all the tags in the current repository .
We can search for tags that match a particular pattern by using git tag -l and then passing in a wildcard pattern .For example, git tag -l "*beta*"
wil print a list of tags that include "beta" in their name.
To view the state of a repo at a particular tag, we can use git checkout <tag>
. This puts us in detached HEAD !
to create a lightweight tag,use git tag <tagname>
. by default, git will create the tag referring to the commit that head is rederencing .
Use git tag -a
to created a new annotated tag . Git will then open you default text editor and prompt you for addtional information. Simmilar to git commit, we can also use the -m option to pass a message directly and forgo the openning of the text editor.
So far , we've seen how to tag the commit that HEAD references . We can create tag an older commit by providing the commit hash : git tag -a
git will yell at us if we try to reuse a tag that is already referring to ad comit . if we use the -f option, we can force our tag throught .
to delete a tag, use git tag -d <tag-name>
git push --tags
By default, the git push command doen't transfer tags to remote servers.If you have a lot of tags that you want to push up at once, you cna use the --tags option to the git push command. this will transfer the tags all of your tag to remote servers that are not already there.