























My notes on using tag feature of Git.
We can use git-tag to create a memorable name for a specific commit, for example, v1.0, v2.0.
There are two different types of tag: lightweight and annotated tag.
To create lightweight tags, do not use -a option:
To create annotated tags, use -a option and -m (for tag message):
git tag -a v0.5 -m "some info about this commit"For annotated tags, when we use git show {tag-name}, the tag message will also be displayed.
To tag a specific commit, we can provide its commit hash:
# in this example, 8a5cbc4 is the commit hash.
git tag -a v1.2 8a5cbc4 -m "some information related to this tag"To list tags, use git tag -l or just git tag.
Git-tag also supports globing for tags matching a pattern.
For example, to list all tags in version 1.1 series, use git tag -l "v1.1.*".
To show a tag, use git show {tag_name}, for example, git show v1.0.
To push a tag to remote repo, we have to explicitly push it.
git push origin {branch-name} does not work in this case.
# this will push tag v1.2 to origin
git push oirgin v1.2To push all tags to remote, use command git push origin --tags.
To delete a tag, use git tag -d {tag-name}, for example, to delete tag v1.2, we use git tag -d v1.2.
To delete a tag in remote repo, use git push {remote-name} -d {tag-name}.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。