一、git tag and describe
1. Create a tag with patterned name
git tag "tagname_v1.02"
(one tag is pointed to a specified commit)
2. get tag describe to use in software version name
git describe --tags --long --dirty=* --match "tagname*"
> tagname_v1.02-0-g59584af
3. push tag name to remote repo
git push origin <branchname> --tags
二、show log with tags
1. show git log with tags:
git log -tags
show tag with no ancestor and within one line:
git log --no-walk --tags --pretty="%h %d %s" --decorate=full
三、tag a specified commit
# Set the HEAD to the old commit that we want to tag
git checkout 9fceb02
# temporarily set the date to the date of the HEAD commit, and add the tag
GIT_COMMITTER_DATE="$(git show --format=%aD | head -1)" \
git tag -a v1.0 -m"v1.0"
注:
这个-m添加的信心只出现在git tag -l -n2里面
没有出现在git log/git log --tags里面
# push to origin
git push origin --tags
# set HEAD back to whatever you want it to be
git checkout master